Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/b00a43139e174ec01fa12a225f4a468c8ed4cf40
...commit
http://git.netsurf-browser.org/netsurf.git/commit/b00a43139e174ec01fa12a225f4a468c8ed4cf40
...tree
http://git.netsurf-browser.org/netsurf.git/tree/b00a43139e174ec01fa12a225f4a468c8ed4cf40
The branch, master has been updated
via b00a43139e174ec01fa12a225f4a468c8ed4cf40 (commit)
via 1beb1e938fe979fb8051126218295fbd878ad9b0 (commit)
from 91d621521580a783b24194a341978dad67b9d6e5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b00a43139e174ec01fa12a225f4a468c8ed4cf40
commit b00a43139e174ec01fa12a225f4a468c8ed4cf40
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
make monkey frontend mime type processing use explicit ascii processing
diff --git a/frontends/monkey/filetype.c b/frontends/monkey/filetype.c
index 2972523..20bd1ed 100644
--- a/frontends/monkey/filetype.c
+++ b/frontends/monkey/filetype.c
@@ -17,21 +17,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * file extension to mimetype mapping for the monkey frontend
+ *
+ * allows monkey frontend to map file extension to mime types using a
+ * default builtin list and /etc/mime.types file if present.
+ *
+ * mime type and content type handling is derived from the BNF in
+ * RFC822 section 3.3, RFC2045 section 5.1 and RFC6838 section
+ * 4.2. Upshot is their charset and parsing is all a strict subset of
+ * ASCII hence not using locale dependant ctype functions for parsing.
+ */
+
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
-#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "utils/log.h"
+#include "utils/ascii.h"
#include "utils/hashtable.h"
#include "monkey/filetype.h"
+#define HASH_SIZE 117
+#define MAX_LINE_LEN 256
+
static struct hash_table *mime_hash = NULL;
void monkey_fetch_filetype_init(const char *mimefile)
@@ -39,17 +55,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
struct stat statbuf;
FILE *fh = NULL;
- mime_hash = hash_create(117);
-
- /* first, check to see if /etc/mime.types in preference */
-
- if ((stat("/etc/mime.types", &statbuf) == 0) &&
- S_ISREG(statbuf.st_mode)) {
- mimefile = "/etc/mime.types";
-
- }
-
- fh = fopen(mimefile, "r");
+ mime_hash = hash_create(HASH_SIZE);
/* Some OSes (mentioning no Solarises) have a worthlessly tiny
* /etc/mime.types that don't include essential things, so we
@@ -69,20 +75,29 @@ void monkey_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "webp", "image/webp");
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
+ /* first, check to see if /etc/mime.types in preference */
+ if ((stat("/etc/mime.types", &statbuf) == 0) &&
+ S_ISREG(statbuf.st_mode)) {
+ mimefile = "/etc/mime.types";
+
+ }
+
+ fh = fopen(mimefile, "r");
+
if (fh == NULL) {
LOG("Unable to open a mime.types file, so using a minimal one
for you.");
return;
}
while (!feof(fh)) {
- char line[256], *ptr, *type, *ext;
- if (fgets(line, 256, fh) == NULL)
+ char line[MAX_LINE_LEN], *ptr, *type, *ext;
+ if (fgets(line, MAX_LINE_LEN, fh) == NULL)
break;
if (!feof(fh) && line[0] != '#') {
ptr = line;
/* search for the first non-whitespace character */
- while (isspace(*ptr))
+ while (ascii_is_space(*ptr))
ptr++;
/* is this line empty other than leading whitespace? */
@@ -93,7 +108,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or NUL or
* NL */
- while (*ptr && (!isspace(*ptr)) && *ptr != '\n')
+ while (*ptr && (!ascii_is_space(*ptr)) && *ptr != '\n')
ptr++;
if (*ptr == '\0' || *ptr == '\n') {
@@ -107,7 +122,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace character which
* will be the first filename extenion */
- while (isspace(*ptr))
+ while (ascii_is_space(*ptr))
ptr++;
while(true) {
@@ -116,7 +131,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first whitespace char or
* NUL or NL which is the end of the ext.
*/
- while (*ptr && (!isspace(*ptr)) &&
+ while (*ptr && (!ascii_is_space(*ptr)) &&
*ptr != '\n')
ptr++;
@@ -135,8 +150,11 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or
* NUL or NL, to find start of next ext.
*/
- while (*ptr && (isspace(*ptr)) && *ptr != '\n')
+ while (*ptr &&
+ (ascii_is_space(*ptr)) &&
+ *ptr != '\n') {
ptr++;
+ }
}
}
}
@@ -203,7 +221,7 @@ const char *monkey_fetch_filetype(const char *unix_path)
*/
lowerchar = ext;
while(*lowerchar) {
- *lowerchar = tolower(*lowerchar);
+ *lowerchar = ascii_to_lower(*lowerchar);
lowerchar++;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=1beb1e938fe979fb8051126218295fbd878ad9b0
commit 1beb1e938fe979fb8051126218295fbd878ad9b0
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
make GTK frontend mime type processing use explicit ascii processing
diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c
index 6b6e41d..154f437 100644
--- a/frontends/gtk/fetch.c
+++ b/frontends/gtk/fetch.c
@@ -17,12 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * file extension to mimetype mapping for the GTK frontend
+ *
+ * allows GTK frontend to map file extension to mime types using a
+ * default builtin list and /etc/mime.types file if present.
+ *
+ * mime type and content type handling is derived from the BNF in
+ * RFC822 section 3.3, RFC2045 section 5.1 and RFC6838 section
+ * 4.2. Upshot is their charset and parsing is all a strict subset of
+ * ASCII hence not using locale dependant ctype functions for parsing.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <gtk/gtk.h>
@@ -32,6 +44,7 @@
#include "utils/filepath.h"
#include "utils/file.h"
#include "utils/nsurl.h"
+#include "utils/ascii.h"
#include "netsurf/fetch.h"
#include "gtk/gui.h"
@@ -50,15 +63,6 @@ void gtk_fetch_filetype_init(const char *mimefile)
mime_hash = hash_create(HASH_SIZE);
- /* first, check to see if /etc/mime.types in preference */
-
- if ((stat("/etc/mime.types", &statbuf) == 0) &&
- S_ISREG(statbuf.st_mode)) {
- mimefile = "/etc/mime.types";
- }
-
- fh = fopen(mimefile, "r");
-
/* Some OSes (mentioning no Solarises) have a worthlessly tiny
* /etc/mime.types that don't include essential things, so we
* pre-seed our hash with the essentials. These will get
@@ -78,6 +82,13 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
hash_add(mime_hash, "bmp", "image/bmp");
+ /* first, check to see if /etc/mime.types in preference */
+ if ((stat("/etc/mime.types", &statbuf) == 0) &&
+ S_ISREG(statbuf.st_mode)) {
+ mimefile = "/etc/mime.types";
+ }
+
+ fh = fopen(mimefile, "r");
if (fh == NULL) {
LOG("Unable to open a mime.types file, so using a minimal one
for you.");
return;
@@ -93,7 +104,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
ptr = line;
/* search for the first non-whitespace character */
- while (isspace(*ptr)) {
+ while (ascii_is_space(*ptr)) {
ptr++;
}
@@ -106,7 +117,9 @@ void gtk_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or NUL or
* NL */
- while (*ptr && (!isspace(*ptr)) && *ptr != '\n') {
+ while (*ptr &&
+ (!ascii_is_space(*ptr)) &&
+ *ptr != '\n') {
ptr++;
}
@@ -121,7 +134,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace character which
* will be the first filename extenion */
- while (isspace(*ptr)) {
+ while (ascii_is_space(*ptr)) {
ptr++;
}
@@ -132,7 +145,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
* NUL or NL which is the end of the ext.
*/
while (*ptr &&
- (!isspace(*ptr)) &&
+ (!ascii_is_space(*ptr)) &&
*ptr != '\n') {
ptr++;
}
@@ -153,7 +166,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
* NUL or NL, to find start of next ext.
*/
while (*ptr &&
- (isspace(*ptr)) &&
+ (ascii_is_space(*ptr)) &&
*ptr != '\n') {
ptr++;
}
@@ -221,7 +234,7 @@ const char *fetch_filetype(const char *unix_path)
*/
lowerchar = ext;
while (*lowerchar) {
- *lowerchar = tolower(*lowerchar);
+ *lowerchar = ascii_to_lower(*lowerchar);
lowerchar++;
}
-----------------------------------------------------------------------
Summary of changes:
frontends/gtk/fetch.c | 45 +++++++++++++++++++++------------
frontends/monkey/filetype.c | 58 ++++++++++++++++++++++++++++---------------
2 files changed, 67 insertions(+), 36 deletions(-)
diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c
index 6b6e41d..154f437 100644
--- a/frontends/gtk/fetch.c
+++ b/frontends/gtk/fetch.c
@@ -17,12 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * file extension to mimetype mapping for the GTK frontend
+ *
+ * allows GTK frontend to map file extension to mime types using a
+ * default builtin list and /etc/mime.types file if present.
+ *
+ * mime type and content type handling is derived from the BNF in
+ * RFC822 section 3.3, RFC2045 section 5.1 and RFC6838 section
+ * 4.2. Upshot is their charset and parsing is all a strict subset of
+ * ASCII hence not using locale dependant ctype functions for parsing.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <gtk/gtk.h>
@@ -32,6 +44,7 @@
#include "utils/filepath.h"
#include "utils/file.h"
#include "utils/nsurl.h"
+#include "utils/ascii.h"
#include "netsurf/fetch.h"
#include "gtk/gui.h"
@@ -50,15 +63,6 @@ void gtk_fetch_filetype_init(const char *mimefile)
mime_hash = hash_create(HASH_SIZE);
- /* first, check to see if /etc/mime.types in preference */
-
- if ((stat("/etc/mime.types", &statbuf) == 0) &&
- S_ISREG(statbuf.st_mode)) {
- mimefile = "/etc/mime.types";
- }
-
- fh = fopen(mimefile, "r");
-
/* Some OSes (mentioning no Solarises) have a worthlessly tiny
* /etc/mime.types that don't include essential things, so we
* pre-seed our hash with the essentials. These will get
@@ -78,6 +82,13 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
hash_add(mime_hash, "bmp", "image/bmp");
+ /* first, check to see if /etc/mime.types in preference */
+ if ((stat("/etc/mime.types", &statbuf) == 0) &&
+ S_ISREG(statbuf.st_mode)) {
+ mimefile = "/etc/mime.types";
+ }
+
+ fh = fopen(mimefile, "r");
if (fh == NULL) {
LOG("Unable to open a mime.types file, so using a minimal one
for you.");
return;
@@ -93,7 +104,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
ptr = line;
/* search for the first non-whitespace character */
- while (isspace(*ptr)) {
+ while (ascii_is_space(*ptr)) {
ptr++;
}
@@ -106,7 +117,9 @@ void gtk_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or NUL or
* NL */
- while (*ptr && (!isspace(*ptr)) && *ptr != '\n') {
+ while (*ptr &&
+ (!ascii_is_space(*ptr)) &&
+ *ptr != '\n') {
ptr++;
}
@@ -121,7 +134,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace character which
* will be the first filename extenion */
- while (isspace(*ptr)) {
+ while (ascii_is_space(*ptr)) {
ptr++;
}
@@ -132,7 +145,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
* NUL or NL which is the end of the ext.
*/
while (*ptr &&
- (!isspace(*ptr)) &&
+ (!ascii_is_space(*ptr)) &&
*ptr != '\n') {
ptr++;
}
@@ -153,7 +166,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
* NUL or NL, to find start of next ext.
*/
while (*ptr &&
- (isspace(*ptr)) &&
+ (ascii_is_space(*ptr)) &&
*ptr != '\n') {
ptr++;
}
@@ -221,7 +234,7 @@ const char *fetch_filetype(const char *unix_path)
*/
lowerchar = ext;
while (*lowerchar) {
- *lowerchar = tolower(*lowerchar);
+ *lowerchar = ascii_to_lower(*lowerchar);
lowerchar++;
}
diff --git a/frontends/monkey/filetype.c b/frontends/monkey/filetype.c
index 2972523..20bd1ed 100644
--- a/frontends/monkey/filetype.c
+++ b/frontends/monkey/filetype.c
@@ -17,21 +17,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * file extension to mimetype mapping for the monkey frontend
+ *
+ * allows monkey frontend to map file extension to mime types using a
+ * default builtin list and /etc/mime.types file if present.
+ *
+ * mime type and content type handling is derived from the BNF in
+ * RFC822 section 3.3, RFC2045 section 5.1 and RFC6838 section
+ * 4.2. Upshot is their charset and parsing is all a strict subset of
+ * ASCII hence not using locale dependant ctype functions for parsing.
+ */
+
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
-#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "utils/log.h"
+#include "utils/ascii.h"
#include "utils/hashtable.h"
#include "monkey/filetype.h"
+#define HASH_SIZE 117
+#define MAX_LINE_LEN 256
+
static struct hash_table *mime_hash = NULL;
void monkey_fetch_filetype_init(const char *mimefile)
@@ -39,17 +55,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
struct stat statbuf;
FILE *fh = NULL;
- mime_hash = hash_create(117);
-
- /* first, check to see if /etc/mime.types in preference */
-
- if ((stat("/etc/mime.types", &statbuf) == 0) &&
- S_ISREG(statbuf.st_mode)) {
- mimefile = "/etc/mime.types";
-
- }
-
- fh = fopen(mimefile, "r");
+ mime_hash = hash_create(HASH_SIZE);
/* Some OSes (mentioning no Solarises) have a worthlessly tiny
* /etc/mime.types that don't include essential things, so we
@@ -69,20 +75,29 @@ void monkey_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "webp", "image/webp");
hash_add(mime_hash, "spr", "image/x-riscos-sprite");
+ /* first, check to see if /etc/mime.types in preference */
+ if ((stat("/etc/mime.types", &statbuf) == 0) &&
+ S_ISREG(statbuf.st_mode)) {
+ mimefile = "/etc/mime.types";
+
+ }
+
+ fh = fopen(mimefile, "r");
+
if (fh == NULL) {
LOG("Unable to open a mime.types file, so using a minimal one
for you.");
return;
}
while (!feof(fh)) {
- char line[256], *ptr, *type, *ext;
- if (fgets(line, 256, fh) == NULL)
+ char line[MAX_LINE_LEN], *ptr, *type, *ext;
+ if (fgets(line, MAX_LINE_LEN, fh) == NULL)
break;
if (!feof(fh) && line[0] != '#') {
ptr = line;
/* search for the first non-whitespace character */
- while (isspace(*ptr))
+ while (ascii_is_space(*ptr))
ptr++;
/* is this line empty other than leading whitespace? */
@@ -93,7 +108,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or NUL or
* NL */
- while (*ptr && (!isspace(*ptr)) && *ptr != '\n')
+ while (*ptr && (!ascii_is_space(*ptr)) && *ptr != '\n')
ptr++;
if (*ptr == '\0' || *ptr == '\n') {
@@ -107,7 +122,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace character which
* will be the first filename extenion */
- while (isspace(*ptr))
+ while (ascii_is_space(*ptr))
ptr++;
while(true) {
@@ -116,7 +131,7 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first whitespace char or
* NUL or NL which is the end of the ext.
*/
- while (*ptr && (!isspace(*ptr)) &&
+ while (*ptr && (!ascii_is_space(*ptr)) &&
*ptr != '\n')
ptr++;
@@ -135,8 +150,11 @@ void monkey_fetch_filetype_init(const char *mimefile)
/* search for the first non-whitespace char or
* NUL or NL, to find start of next ext.
*/
- while (*ptr && (isspace(*ptr)) && *ptr != '\n')
+ while (*ptr &&
+ (ascii_is_space(*ptr)) &&
+ *ptr != '\n') {
ptr++;
+ }
}
}
}
@@ -203,7 +221,7 @@ const char *monkey_fetch_filetype(const char *unix_path)
*/
lowerchar = ext;
while(*lowerchar) {
- *lowerchar = tolower(*lowerchar);
+ *lowerchar = ascii_to_lower(*lowerchar);
lowerchar++;
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org