This patch fixes the handling of \pict's which was broken when nopict_mode was introduced to convert.c. Before nopict_mode was there, pictfile was used to control the "reset" of within_picture to FALSE. After the "nopict_mode changes" and without this patch, within_picture gets reset too early when the \pict has sub-groups/children because within_picture is a global variable and word_print_core() is used recursively. We need a local variable to control this operation, and this patch introduces the new local variable in_pict_data for this purpose. diff -u unrtf_0.20.2/src/convert.c.in_pict unrtf_0.20.2/src/convert.c --- unrtf_0.20.2/src/convert.c.in_pict 2006-06-18 10:52:33.000000000 +0200 +++ unrtf_0.20.2/src/convert.c 2006-08-04 10:29:19.000000000 +0200 @@ -3280,6 +3280,7 @@ { char *s; FILE *pictfile=NULL; + int in_pict_data=FALSE; int is_cell_group=FALSE; int paragraph_begined=FALSE; int paragraph_align=ALIGN_LEFT; @@ -3319,20 +3320,23 @@ /*----------------------------------------*/ if (within_picture) { starting_body(); - if (!pictfile && !nopict_mode) { - char *ext=NULL; - switch (picture_type) { - case PICT_WB: ext="bmp"; break; - case PICT_WM: ext="wmf"; break; - case PICT_MAC: ext="pict"; break; - case PICT_JPEG: ext="jpg"; break; - case PICT_PNG: ext="png"; break; - case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */ - case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */ + if (!in_pict_data) { + in_pict_data=TRUE; + if (!nopict_mode) { + char *ext=NULL; + switch (picture_type) { + case PICT_WB: ext="bmp"; break; + case PICT_WM: ext="wmf"; break; + case PICT_MAC: ext="pict"; break; + case PICT_JPEG: ext="jpg"; break; + case PICT_PNG: ext="png"; break; + case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */ + case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */ + } + sprintf(picture_path, "pict%03d.%s", + picture_file_number++,ext); + pictfile=fopen(picture_path,"w"); } - sprintf(picture_path, "pict%03d.%s", - picture_file_number++,ext); - pictfile=fopen(picture_path,"w"); } if (s[0]!=' ') { @@ -3586,7 +3590,7 @@ w = w->next; } - if (within_picture) { + if (in_pict_data) { if(pictfile) { fclose(pictfile); printf(op->imagelink_begin);