if ((len = strlen(path)) > 3) { if (!strcasecomp(&path[len-3], "bz2")) { path[len-4] = '\0'; remove(path); } else if (!strcasecomp(&path[len-2], "gz")) {
if ((len = strlen(path)) > 3 && !strcasecomp(&path[len-2], "gz")) {
PRIVATE void HTFWriter_free ARGS1(HTStream *, me){    FILE *fp = NULL;    int len;    char *path = NULL;    char *addr = NULL;    int status;    BOOL use_gzread = NO;    fflush(me->fp);    if (me->end_command) {		/* Temp file */	LYCloseTempFP(me->fp);#ifdef VMS	if (0 == strcmp(me->end_command, "SaveVMSBinaryFile")) {	/*	 *  It's a binary file saved to disk on VMS, which	 *  we want to convert to fixed records format. - FM	 */#ifdef USE_COMMAND_FILE	    LYSystem(FIXED_RECORD_COMMAND);#else	    LYVMS_FixedLengthRecords(FIXED_RECORD_COMMAND);#endif /* USE_COMMAND_FILE */	    FREE(FIXED_RECORD_COMMAND);	    if (me->remove_command) {		/* NEVER REMOVE THE FILE unless during an abort!*/		FREE(me->remove_command);	    }	} else#endif /* VMS */	if (me->input_format == HTAtom_for("www/compressed")) {	    /*	     *	It's a compressed file supposedly cached to	     *	a temporary file for uncompression. - FM	     */	    if (me->anchor->FileCache != NULL) {		BOOL skip_loadfile = (me->viewer_command != NULL);		/*		 *  Save the path with the "gz" or "Z" suffix trimmed,		 *  and remove any previous uncompressed copy. - FM		 */		StrAllocCopy(path, me->anchor->FileCache);		if ((len = strlen(path)) > 3) {		    if (!strcasecomp(&path[len-3], "bz2")) {			    path[len-4] = '\0';			    remove(path);		    } else if (!strcasecomp(&path[len-2], "gz")) {#ifdef USE_ZLIB			if (!skip_loadfile) {			    use_gzread = YES;			} else#endif /* USE_ZLIB */			{			    path[len-3] = '\0';			    remove(path);			}		    } else if (!strcasecomp(&path[len-1], "Z")) {			path[len-2] = '\0';			remove(path);		    }		}		if (!use_gzread) {		    if (!dump_output_immediately) {			/*			 *  Tell user what's happening. - FM			 */			_HTProgress(me->end_command);		    }		    /*		     *	Uncompress it. - FM		     */		    if (me->end_command && me->end_command[0])			LYSystem(me->end_command);		    fp = fopen(me->anchor->FileCache, "r");		}		if (fp != NULL) {		    /*		     *	It's still there with the "gz" or "Z" suffix,		     *	so the uncompression failed. - FM		     */		    fclose(fp);		    fp = NULL;		    if (!dump_output_immediately) {			lynx_force_repaint();			refresh();		    }		    HTAlert(ERROR_UNCOMPRESSING_TEMP);		    remove(me->anchor->FileCache);		    FREE(me->anchor->FileCache);		} else {		    /*		     *	Succeeded!  Create a complete address		     *	for the uncompressed file and invoke		     *	HTLoadFile() to handle it. - FM		     */#ifdef FNAMES_8_3		    /*		     *	Assuming we have just uncompressed e.g.		     *	FILE-mpeg.gz -> FILE-mpeg, restore/shorten		     *	the name to be fit for passing to an external		     *	viewer, by renaming FILE-mpeg -> FILE.mpe  - kw		     */		    if (skip_loadfile) {			char *new_path = NULL;			char *the_dash = me->idash ? strrchr(path, '-') : 0;			if (the_dash != 0) {			    unsigned off = (the_dash - path);			    StrAllocCopy(new_path, path);			    new_path[off] = '.';			    if (strlen(new_path + off) > 4)				new_path[off + 4] = '\0';			    if (rename(path, new_path) == 0) {				FREE(path);				path = new_path;			    } else {				FREE(new_path);			    }			}		    }#endif /* FNAMES_8_3 */		    LYLocalFileToURL (&addr, path);		    if (!use_gzread) {			LYRenamedTemp(me->anchor->FileCache, path);			StrAllocCopy(me->anchor->FileCache, path);			StrAllocCopy(me->anchor->content_encoding, "binary");		    }		    FREE(path);		    if (!skip_loadfile) {			/*			 *  Lock the chartrans info we may possibly have,			 *  so HTCharsetFormat() will not apply the default			 *  for local files. - KW			 */			if (HTAnchor_getUCLYhndl(me->anchor,						 UCT_STAGE_PARSER) < 0 ) {			    /*			     *	If not yet set - KW			     */			    HTAnchor_copyUCInfoStage(me->anchor,						     UCT_STAGE_PARSER,						     UCT_STAGE_MIME,						     UCT_SETBY_DEFAULT+1);			}			HTAnchor_copyUCInfoStage(me->anchor,						 UCT_STAGE_PARSER,						 UCT_STAGE_MIME, -1);		    }		    /*		     *	Create a complete address for		     *	the uncompressed file. - FM		     */		    if (!dump_output_immediately) {			/*			 *  Tell user what's happening. - FM			 */			_user_message(WWW_USING_MESSAGE, addr);		    }		    if (skip_loadfile) {			/*			 *  It's a temporary file we're passing to a			 *  viewer or helper application.			 *  Loading the temp file through HTLoadFile()			 *  would result in yet another HTStream (created			 *  with HTSaveAndExecute()) which would just			 *  copy the temp file to another temp file			 *  (or even the same!).  We can skip this			 *  needless duplication by using the			 *  viewer_command which has already been			 *  determined when the HTCompressed stream was			 *  created. - kw			 */			FREE(me->end_command);			HTAddParam(&(me->end_command), me->viewer_command, 1, me->anchor->FileCache);			HTEndParam(&(me->end_command), me->viewer_command, 1);			if (!dump_output_immediately) {			    /*			     *	Tell user what's happening. - FM			     */			    HTProgress(me->end_command);			    stop_curses();			}			LYSystem(me->end_command);			if (me->remove_command) {			    /* NEVER REMOVE THE FILE unless during an abort!!!*/			    FREE(me->remove_command);			}			if (!dump_output_immediately)			    start_curses();		    } else		    status = HTLoadFile(addr,					me->anchor,					me->output_format,					me->sink);		    if (dump_output_immediately &&			me->output_format == HTAtom_for("www/present")) {			FREE(addr);			remove(me->anchor->FileCache);			FREE(me->anchor->FileCache);			FREE(me->remove_command);			FREE(me->end_command);			FREE(me->viewer_command);			FREE(me);			return;		    }		}		FREE(addr);	    }	    if (me->remove_command) {		/* NEVER REMOVE THE FILE unless during an abort!!!*/		FREE(me->remove_command);	    }	} else if (strcmp(me->end_command, "SaveToFile")) {	    /*	     *	It's a temporary file we're passing to a	     *	viewer or helper application. - FM	     */	    if (!dump_output_immediately) {		/*		 *  Tell user what's happening. - FM		 */		_HTProgress(me->end_command);		stop_curses();	    }	    LYSystem(me->end_command);	    if (me->remove_command) {		/* NEVER REMOVE THE FILE unless during an abort!!!*/		FREE(me->remove_command);	    }	    if (!dump_output_immediately)		start_curses();	} else {	    /*	     *	It's a file we saved to disk for handling	     *	via a menu. - FM	     */	    if (me->remove_command) {		/* NEVER REMOVE THE FILE unless during an abort!!!*/		FREE(me->remove_command);	    }	}	FREE(me->end_command);    }    FREE(me->viewer_command);    if (dump_output_immediately) {	if (me->anchor->FileCache)	    remove(me->anchor->FileCache);	FREE(me);	exit_immediately(0);    }    FREE(me);    return;}