"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/convert.c" between
unrtf-0.21.8.tar.gz and unrtf-0.21.9.tar.gz

About: unrtf is a converter from RTF to other formats like HTML, latex, vt, or plain text.

convert.c  (unrtf-0.21.8):convert.c  (unrtf-0.21.9)
skipping to change at line 145 skipping to change at line 145
my_iconv_t desc = MY_ICONV_T_CLEAR; my_iconv_t desc = MY_ICONV_T_CLEAR;
/* Nested tables aren't supported. /* Nested tables aren't supported.
*/ */
static int coming_pars_that_are_tabular = 0; static int coming_pars_that_are_tabular = 0;
static int within_table = FALSE; static int within_table = FALSE;
static int have_printed_row_begin=FALSE; static int have_printed_row_begin=FALSE;
static int have_printed_cell_begin=FALSE; static int have_printed_cell_begin=FALSE;
static int have_printed_row_end=FALSE; static int have_printed_row_end=FALSE;
static int have_printed_cell_end=FALSE; static int have_printed_cell_end=FALSE;
static void check_for_table();
/* Previously in word_print_core function /* Previously in word_print_core function
*/ */
static int total_chars_this_line=0; /* for simulating \tab */ static int total_chars_this_line=0; /* for simulating \tab */
/* Paragraph alignment (kludge) /* Paragraph alignment (kludge)
*/ */
enum { enum {
ALIGN_LEFT=0, ALIGN_LEFT=0,
ALIGN_RIGHT, ALIGN_RIGHT,
skipping to change at line 187 skipping to change at line 188
static int within_picture_depth; static int within_picture_depth;
static int picture_file_number=1; static int picture_file_number=1;
static char picture_path[255]; static char picture_path[255];
static int picture_width; static int picture_width;
static int picture_height; static int picture_height;
static int picture_bits_per_pixel=1; static int picture_bits_per_pixel=1;
static int picture_type=PICT_UNKNOWN; static int picture_type=PICT_UNKNOWN;
static int picture_wmetafile_type; static int picture_wmetafile_type;
static char *picture_wmetafile_type_str; static char *picture_wmetafile_type_str;
static int within_citation=FALSE; static int EndNoteCitations=FALSE;
static int have_printed_body=FALSE; static int have_printed_body=FALSE;
static int within_header=TRUE; static int within_header=TRUE;
static const char *hyperlink_base = NULL; static const char *hyperlink_base = NULL;
void starting_body(); void starting_body();
void starting_text(); void starting_text();
void print_with_special_exprs (const char *s); void print_with_special_exprs (const char *s);
skipping to change at line 1076 skipping to change at line 1077
} }
while (w3 && !w3->child) { while (w3 && !w3->child) {
w3=w3->next; w3=w3->next;
} }
if (w3) w3=w3->child; if (w3) w3=w3->child;
while (w3) while (w3)
{ {
const char *s3=word_string(w3); const char *s3=word_string(w3);
if (s3 && !strcmp("EN.CITE", s3)) if (s3 && !strcmp("EN.CITE", s3))
{ {
if(0)fprintf(stderr, "got EN.CITE EndNoteCitations = TRUE;
\n");
within_citation = TRUE;
} }
if (within_citation) /*
if(0)fprintf(stderr,"%s\n", s3); ** If we have a file with EndNote
if (s3 && !strcmp("HYPERLINK",s3)) { ** citations, we don't want to
** insert "hyperlink", we want the
** citation text, so we return
** FALSE. (We could extract "<url>"
** for a link, but probably not
** wanted.)
*/
if (s3 && !strcmp("HYPERLINK",s3) &&
!EndNoteCitations) {
Word *w4; Word *w4;
const char *s4; const char *s4;
w4=w3->next; w4=w3->next;
while (w4 && word_string(w4) && !strcmp(" ", word_string(w4))) while (w4 && word_string(w4) && !strcmp(" ", word_string(w4)))
w4=w4->next; w4=w4->next;
if (w4) { if (w4) {
s4=word_string(w4); s4=word_string(w4);
if (safe_printf(0, op ->hyperlink_begin)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_begin"); if (safe_printf(0, op ->hyperlink_begin)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_begin");
printf("%s", s4); printf("%s", s4);
if (safe_printf(0, op ->hyperlink_end)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_end"); if (safe_printf(0, op ->hyperlink_end)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_end");
return TRUE; return TRUE;
} }
} }
else
return FALSE;
w3=w3->next; w3=w3->next;
} }
} }
w2 = w2->next; w2 = w2->next;
} }
} }
} }
w=w->next; w=w->next;
} }
skipping to change at line 1629 skipping to change at line 1639
/*======================================================================== /*========================================================================
* Name: cmd_intbl * Name: cmd_intbl
* Purpose: Executes the \intbl command. * Purpose: Executes the \intbl command.
* Args: Word, paragraph align info, and numeric param if any. * Args: Word, paragraph align info, and numeric param if any.
* Returns: Flag, true only if rest of Words on line should be ignored. * Returns: Flag, true only if rest of Words on line should be ignored.
*=======================================================================*/ *=======================================================================*/
static int cmd_intbl (Word *w, int align, char has_param, int param) { static int cmd_intbl (Word *w, int align, char has_param, int param) {
++coming_pars_that_are_tabular; ++coming_pars_that_are_tabular;
check_for_table();
return FALSE; return FALSE;
} }
/*======================================================================== /*========================================================================
* Name: cmd_ulnone * Name: cmd_ulnone
* Purpose: Executes the \ulnone command. * Purpose: Executes the \ulnone command.
* Args: Word, paragraph align info, and numeric param if any. * Args: Word, paragraph align info, and numeric param if any.
* Returns: Flag, true only if rest of Words on line should be ignored. * Returns: Flag, true only if rest of Words on line should be ignored.
*=======================================================================*/ *=======================================================================*/
skipping to change at line 2782 skipping to change at line 2795
{ "shppict", &cmd_shppict, "shppict wrapper" }, { "shppict", &cmd_shppict, "shppict wrapper" },
#if 0 #if 0
{ "shading", NULL, NULL }, { "shading", NULL, NULL },
#endif #endif
{ NULL, NULL, NULL} { NULL, NULL, NULL}
}; };
static HashItem hashArray_t [] = { static HashItem hashArray_t [] = {
{ "tab", &cmd_tab, NULL }, { "tab", &cmd_tab, NULL },
{ "tc", cmd_tc, "TOC entry" }, { "tc", cmd_tc, "TOC entry" },
{ "tcn", cmd_tcn, "TOC entry" }, { "tcn", cmd_tcn, "TOC entry" },
{ "trowd", NULL, "start new row in table" },
{ NULL, NULL, NULL} { NULL, NULL, NULL}
}; };
static HashItem hashArray_u [] = { static HashItem hashArray_u [] = {
{ "u", &cmd_u, NULL }, { "u", &cmd_u, NULL },
{ "ul", &cmd_ul, NULL }, { "ul", &cmd_ul, NULL },
{ "up", &cmd_up, NULL }, { "up", &cmd_up, NULL },
{ "uld", &cmd_uld, NULL }, { "uld", &cmd_uld, NULL },
{ "uldash", &cmd_uldash, NULL }, { "uldash", &cmd_uldash, NULL },
{ "uldashd", &cmd_uldashd, NULL }, { "uldashd", &cmd_uldashd, NULL },
{ "uldashdd", &cmd_uldashdd, NULL }, { "uldashdd", &cmd_uldashdd, NULL },
skipping to change at line 2864 skipping to change at line 2878
* hasparamp: parameter existence flag (output) * hasparamp: parameter existence flag (output)
* paramp: parameter value if hasparamp is set * paramp: parameter value if hasparamp is set
* Returns: Pointer to command structure, or NULL * Returns: Pointer to command structure, or NULL
*=======================================================================*/ *=======================================================================*/
static HashItem *find_command(const char *cmdpp, int *hasparamp, int *paramp) static HashItem *find_command(const char *cmdpp, int *hasparamp, int *paramp)
{ {
HashItem *hip; HashItem *hip;
int ch; int ch;
const char *p; /* Start of parameter */ const char *p; /* Start of parameter */
int len;
/* Look for a parameter */ /* Look for a parameter */
*hasparamp = FALSE;
p = cmdpp; p = cmdpp;
while (*p && (!isdigit(*p) && *p != '-')) while (*p && (!isdigit(*p) && *p != '-'))
p++; p++;
if (*p && (isdigit(*p) || *p == '-')) { if (*p && (isdigit(*p) || *p == '-')) {
*hasparamp = TRUE; *hasparamp = TRUE;
*paramp = atoi(p); *paramp = atoi(p);
} }
len = p - cmdpp;
/* Generate a hash index */ /* Generate a hash index */
ch = tolower(*cmdpp); ch = tolower(*cmdpp);
if (ch >= 'a' && ch <= 'z') if (ch >= 'a' && ch <= 'z')
hip = hash[ch - 'a']; hip = hash[ch - 'a'];
else else
hip = hashArray_other; hip = hashArray_other;
if (!hip) { if (!hip) {
if (debug_mode) { if (debug_mode) {
if (safe_printf(0, op->comment_begin)) fprintf(stderr, TO O_MANY_ARGS, "comment_begin"); if (safe_printf(0, op->comment_begin)) fprintf(stderr, TO O_MANY_ARGS, "comment_begin");
printf("Unfamiliar RTF command: %s (HashIndex not found)" , cmdpp); printf("Unfamiliar RTF command: %s (HashIndex not found)" , cmdpp);
if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_ MANY_ARGS, "comment_end"); if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_ MANY_ARGS, "comment_end");
} }
return NULL; return NULL;
} }
while (hip->name) { while (hip->name) {
if (*hasparamp) { /* Don't change the order of tests ! */
int len = p - cmdpp; if (!strncmp(cmdpp, hip->name, len) && hip->name[len] == 0)
/* Don't change the order of tests ! */ return hip;
if (!strncmp(cmdpp, hip->name, len) && hip->name[len] ==
0)
return hip;
} else {
if (!strcmp(cmdpp, hip->name))
return hip;
}
hip++; hip++;
} }
if (debug_mode) { if (debug_mode) {
if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_A RGS, "comment_begin"); if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_A RGS, "comment_begin");
printf("Unfamiliar RTF command: %s", cmdpp); printf("Unfamiliar RTF command: %s", cmdpp);
if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARG S, "comment_end"); if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARG S, "comment_end");
} }
return NULL; return NULL;
} }
skipping to change at line 3006 skipping to change at line 3016
have_printed_row_begin = FALSE; have_printed_row_begin = FALSE;
have_printed_cell_begin = FALSE; have_printed_cell_begin = FALSE;
have_printed_row_end = FALSE; have_printed_row_end = FALSE;
have_printed_cell_end = FALSE; have_printed_cell_end = FALSE;
attrstack_push(); attrstack_push();
starting_body(); starting_body();
if (safe_printf(0, op->table_begin)) fprintf(stderr, TOO_MANY_ARGS, "tabl e_begin"); if (safe_printf(0, op->table_begin)) fprintf(stderr, TOO_MANY_ARGS, "tabl e_begin");
} }
/*======================================================================== /*========================================================================
* Name: * Name: end_table
* Purpose: * Purpose: finish off table
* Args: None. * Args: None.
* Returns: None. * Returns: None.
*=======================================================================*/ *=======================================================================*/
void void
end_table () end_table ()
{ {
if (within_table) { if (within_table) {
if (!have_printed_cell_end) { if (!have_printed_cell_end) {
attr_pop_dump(); attr_pop_dump();
skipping to change at line 3032 skipping to change at line 3042
} }
if (safe_printf(0, op->table_end)) fprintf(stderr, TOO_MANY_ARGS, "table_end"); if (safe_printf(0, op->table_end)) fprintf(stderr, TOO_MANY_ARGS, "table_end");
within_table=FALSE; within_table=FALSE;
have_printed_row_begin = FALSE; have_printed_row_begin = FALSE;
have_printed_cell_begin = FALSE; have_printed_cell_begin = FALSE;
have_printed_row_end = FALSE; have_printed_row_end = FALSE;
have_printed_cell_end = FALSE; have_printed_cell_end = FALSE;
} }
} }
/*=======================================================================
* Name: check_for_table
* Purpose: make certain table has been started
* Args: None.
* Returns: None.
*=======================================================================*/
static void check_for_table()
{
//printf("EH: %d %d", coming_pars_that_are_tabular, within_table);
if (!coming_pars_that_are_tabular && within_table)
{
//printf("END TABLE\n");
end_table();
}
else if (coming_pars_that_are_tabular && !within_table)
{
//printf("BEGIN TABLE");
begin_table();
}
}
/*======================================================================== /*========================================================================
* Name: * Name:
* Purpose: * Purpose:
* Args: None. * Args: None.
* Returns: None. * Returns: None.
*=======================================================================*/ *=======================================================================*/
void void
starting_text() { starting_text() {
if (within_table) { if (within_table) {
skipping to change at line 3205 skipping to change at line 3238
int is_cell_group=FALSE; int is_cell_group=FALSE;
int paragraph_begined=FALSE; int paragraph_begined=FALSE;
int paragraph_align=ALIGN_LEFT; int paragraph_align=ALIGN_LEFT;
if (groupdepth > MAX_GROUP_DEPTH) { if (groupdepth > MAX_GROUP_DEPTH) {
warning_handler ("Max group depth reached"); warning_handler ("Max group depth reached");
return; return;
} }
CHECK_PARAM_NOT_NULL(w); CHECK_PARAM_NOT_NULL(w);
if (!coming_pars_that_are_tabular && within_table) { //if (!coming_pars_that_are_tabular && within_table) {
end_table(); //end_table();
} //}
else if (coming_pars_that_are_tabular && !within_table) { //else if (coming_pars_that_are_tabular && !within_table) {
begin_table(); //begin_table();
} //}
check_for_table();
/* Mark our place in the stack */ /* Mark our place in the stack */
attrstack_push(); attrstack_push();
while (w) { while (w) {
s = word_string (w); s = word_string (w);
// If we have hex data and we're getting out of the hex area // If we have hex data and we're getting out of the hex area
// flush it. // flush it.
if (iconv_cur > 0 && s && strncmp(s, "\\'", 2)) if (iconv_cur > 0 && s && strncmp(s, "\\'", 2))
 End of changes. 15 change blocks. 
27 lines changed or deleted 60 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS