"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "htmldoc/file.c" between
htmldoc-1.9.11-source.tar.gz and htmldoc-1.9.12-source.tar.gz

About: HTMLDOC converts HTML and Markdown source files into indexed HTML, EPUB, PostScript, or PDF files (but doesn’t support CSS).

file.c  (htmldoc-1.9.11-source):file.c  (htmldoc-1.9.12-source)
/* /*
* Filename routines for HTMLDOC, a HTML document processing program. * Filename routines for HTMLDOC, a HTML document processing program.
* *
* Copyright © 2011-2019 by Michael R Sweet. * Copyright © 2011-2021 by Michael R Sweet.
* Copyright © 1997-2010 by Easy Software Products. All rights reserved. * Copyright © 1997-2010 by Easy Software Products. All rights reserved.
* *
* This program is free software. Distribution and use rights are outlined in * This program is free software. Distribution and use rights are outlined in
* the file "COPYING". * the file "COPYING".
*/ */
/* /*
* Include necessary headers. * Include necessary headers.
*/ */
skipping to change at line 294 skipping to change at line 294
} }
/* /*
* 'file_extension()' - Return the extension of a file without the target. * 'file_extension()' - Return the extension of a file without the target.
*/ */
const char * /* O - File extension */ const char * /* O - File extension */
file_extension(const char *s) /* I - Filename or URL */ file_extension(const char *s) /* I - Filename or URL */
{ {
const char *extension; /* Pointer to directory separator */ const char *extension; /* Pointer to directory separator */
char *bufptr; /* Pointer into buffer */
static char buf[1024]; /* Buffer for files with targets */ static char buf[1024]; /* Buffer for files with targets */
if (s == NULL) if (s == NULL)
return (NULL); return (NULL);
else if (!strncmp(s, "data:image/bmp;", 15)) else if (!strncmp(s, "data:image/bmp;", 15))
return ("bmp"); return ("bmp");
else if (!strncmp(s, "data:image/gif;", 15)) else if (!strncmp(s, "data:image/gif;", 15))
return ("gif"); return ("gif");
else if (!strncmp(s, "data:image/jpeg;", 16)) else if (!strncmp(s, "data:image/jpeg;", 16))
return ("jpg"); return ("jpg");
skipping to change at line 323 skipping to change at line 324
if ((extension = strrchr(extension, '.')) == NULL) if ((extension = strrchr(extension, '.')) == NULL)
return (""); return ("");
else else
extension ++; extension ++;
if (strchr(extension, '#') == NULL) if (strchr(extension, '#') == NULL)
return (extension); return (extension);
strlcpy(buf, extension, sizeof(buf)); strlcpy(buf, extension, sizeof(buf));
*(char *)strchr(buf, '#') = '\0'; if ((bufptr = strchr(buf, '#')) != NULL)
*bufptr = '\0';
return (buf); return (buf);
} }
/* /*
* 'file_find_check()' - Check to see if the specified file or URL exists... * 'file_find_check()' - Check to see if the specified file or URL exists...
*/ */
static const char * /* O - Pathname or NULL */ static const char * /* O - Pathname or NULL */
file_find_check(const char *filename) /* I - File or URL */ file_find_check(const char *filename) /* I - File or URL */
skipping to change at line 607 skipping to change at line 609
if (s == NULL) if (s == NULL)
return (NULL); return (NULL);
DEBUG_printf(("file_find(path=\"%s\", s=\"%s\")\n", path ? path : "(null)", s) ); DEBUG_printf(("file_find(path=\"%s\", s=\"%s\")\n", path ? path : "(null)", s) );
/* /*
* See if this is a cached remote file... * See if this is a cached remote file...
*/ */
for (i = 0; i < (int)web_files; i ++) for (i = 0; i < (int)web_files; i ++)
{
if (strcmp(s, web_cache[i].name) == 0) if (strcmp(s, web_cache[i].name) == 0)
{ {
DEBUG_printf(("file_find: Returning cache file \"%s\"!\n", s)); DEBUG_printf(("file_find: Returning cache file \"%s\"!\n", s));
return (s); return (web_cache[i].name);
} }
}
DEBUG_printf(("file_find: \"%s\" not in web cache of %d files...\n", s, (int)w eb_files)); DEBUG_printf(("file_find: \"%s\" not in web cache of %d files...\n", s, (int)w eb_files));
/* /*
* Make sure the filename is not quoted... * Make sure the filename is not quoted...
*/ */
if (strchr(s, '%') == NULL) if (strchr(s, '%') == NULL)
{
strlcpy(basename, s, sizeof(basename)); strlcpy(basename, s, sizeof(basename));
}
else else
{ {
for (sptr = s, temp = basename; for (sptr = s, temp = basename;
*sptr && temp < (basename + sizeof(basename) - 1);) *sptr && temp < (basename + sizeof(basename) - 1);)
{
if (*sptr == '%' && isxdigit(sptr[1]) && isxdigit(sptr[2])) if (*sptr == '%' && isxdigit(sptr[1]) && isxdigit(sptr[2]))
{ {
/* /*
* Dequote %HH... * Dequote %HH...
*/ */
if (isalpha(sptr[1])) if (isalpha(sptr[1]))
ch = (tolower(sptr[1]) - 'a' + 10) << 4; ch = (tolower(sptr[1]) - 'a' + 10) << 4;
else else
ch = (sptr[1] - '0') << 4; ch = (sptr[1] - '0') << 4;
skipping to change at line 647 skipping to change at line 654
ch |= tolower(sptr[2]) - 'a' + 10; ch |= tolower(sptr[2]) - 'a' + 10;
else else
ch |= sptr[2] - '0'; ch |= sptr[2] - '0';
*temp++ = (char)ch; *temp++ = (char)ch;
sptr += 3; sptr += 3;
} }
else else
*temp++ = *sptr++; *temp++ = *sptr++;
}
*temp = '\0'; *temp = '\0';
} }
/* /*
* If we got a complete URL, we don't use the path... * If we got a complete URL, we don't use the path...
*/ */
if (path != NULL && !path[0]) if (path != NULL && !path[0])
{ {
skipping to change at line 896 skipping to change at line 904
/* /*
* 'file_method()' - Return the method for a filename or URL. * 'file_method()' - Return the method for a filename or URL.
* *
* Returns NULL if the URL is a local file. * Returns NULL if the URL is a local file.
*/ */
const char * /* O - Method string ("http", "ftp", etc.) */ const char * /* O - Method string ("http", "ftp", etc.) */
file_method(const char *s) /* I - Filename or URL */ file_method(const char *s) /* I - Filename or URL */
{ {
if (strncmp(s, "http:", 5) == 0) if (strncmp(s, "data:", 5) == 0)
return ("data");
else if (strncmp(s, "http:", 5) == 0)
return ("http"); return ("http");
else if (strncmp(s, "https:", 6) == 0) else if (strncmp(s, "https:", 6) == 0)
return ("https"); return ("https");
else if (strncmp(s, "ftp:", 4) == 0) else if (strncmp(s, "ftp:", 4) == 0)
return ("ftp"); return ("ftp");
else if (strncmp(s, "mailto:", 7) == 0) else if (strncmp(s, "mailto:", 7) == 0)
return ("mailto"); return ("mailto");
else else
return (NULL); return (NULL);
} }
skipping to change at line 974 skipping to change at line 984
* 'file_rlookup()' - Lookup a filename to find the original URL, if applicable. * 'file_rlookup()' - Lookup a filename to find the original URL, if applicable.
*/ */
const char * /* O - URL or filename */ const char * /* O - URL or filename */
file_rlookup(const char *filename) /* I - Filename */ file_rlookup(const char *filename) /* I - Filename */
{ {
int i; /* Looping var */ int i; /* Looping var */
cache_t *wc; /* Current cache file */ cache_t *wc; /* Current cache file */
for (i = web_files, wc = web_cache; i > 0; i --, wc ++) for (i = web_files, wc = web_cache; i > 0; i --, wc ++)
{
if (!strcmp(wc->name, filename)) if (!strcmp(wc->name, filename))
return (wc->url); {
if (!strncmp(wc->url, "data:", 5))
return ("data URL");
else
return (wc->url);
}
}
return (filename); return (filename);
} }
/* /*
* 'file_target()' - Return the target of a link. * 'file_target()' - Return the target of a link.
*/ */
const char * /* O - Target name */ const char * /* O - Target name */
file_target(const char *s) /* I - Filename or URL */ file_target(const char *s) /* I - Filename or URL */
 End of changes. 13 change blocks. 
5 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)