View | Details | Raw Unified | Return to bug 8196
Collapse All | Expand All

(-)htmldoc-1.8.23.orig/htmldoc/htmldoc.cxx (-3 / +30 lines)
Lines 83-88 Link Here
83
static void	term_handler(int signum);
83
static void	term_handler(int signum);
84
static void	usage(void);
84
static void	usage(void);
85
85
86
/*
87
 * Local variables...
88
 */
89
90
int autocharset = 0;
91
86
92
87
/*
93
/*
88
 * 'main()' - Main entry for HTMLDOC.
94
 * 'main()' - Main entry for HTMLDOC.
Lines 247-253 Link Here
247
    {
253
    {
248
      i ++;
254
      i ++;
249
      if (i < argc)
255
      if (i < argc)
250
        htmlSetCharSet(argv[i]);
256
      {
257
        if (strcmp(argv[i], "auto") == 0) 
258
	{
259
	  autocharset = 1;
260
	}
261
	else htmlSetCharSet(argv[i]);
262
      }
251
      else
263
      else
252
        usage();
264
        usage();
253
    }
265
    }
Lines 1034-1039 Link Here
1034
1046
1035
  while (document->prev != NULL)
1047
  while (document->prev != NULL)
1036
    document = document->prev;
1048
    document = document->prev;
1049
    
1050
  if (autocharset)
1051
    htmlSetMetaCharSet(document);
1037
1052
1038
  htmlDebugStats("Document Tree", document);
1053
  htmlDebugStats("Document Tree", document);
1039
1054
Lines 1269-1275 Link Here
1269
      else if (strncasecmp(line, "XRXCOMMENTS=", 12) == 0)
1284
      else if (strncasecmp(line, "XRXCOMMENTS=", 12) == 0)
1270
	XRXComments = atoi(line + 12);
1285
	XRXComments = atoi(line + 12);
1271
      else if (strncasecmp(line, "CHARSET=", 8) == 0)
1286
      else if (strncasecmp(line, "CHARSET=", 8) == 0)
1272
	htmlSetCharSet(line + 8);
1287
      {
1288
	if (strcmp(line + 8, "auto") == 0) 
1289
	{
1290
	  autocharset = 1;
1291
	}
1292
	else htmlSetCharSet(line + 8);
1293
      }
1273
      else if (strncasecmp(line, "PAGEMODE=", 9) == 0)
1294
      else if (strncasecmp(line, "PAGEMODE=", 9) == 0)
1274
	PDFPageMode = atoi(line + 9);
1295
	PDFPageMode = atoi(line + 9);
1275
      else if (strncasecmp(line, "PAGELAYOUT=", 11) == 0)
1296
      else if (strncasecmp(line, "PAGELAYOUT=", 11) == 0)
Lines 1994-2000 Link Here
1994
      }
2015
      }
1995
    }
2016
    }
1996
    else if (strcmp(temp, "--charset") == 0)
2017
    else if (strcmp(temp, "--charset") == 0)
1997
      htmlSetCharSet(temp2);
2018
    {
2019
      if (strcmp(temp2, "auto") == 0)
2020
      {
2021
        autocharset = 1;
2022
      }
2023
      else htmlSetCharSet(temp2);
2024
    }
1998
    else if (strcmp(temp, "--pagemode") == 0)
2025
    else if (strcmp(temp, "--pagemode") == 0)
1999
    {
2026
    {
2000
      for (i = 0; i < (int)(sizeof(PDFModes) / sizeof(PDFModes[0])); i ++)
2027
      for (i = 0; i < (int)(sizeof(PDFModes) / sizeof(PDFModes[0])); i ++)
(-)htmldoc-1.8.23.orig/htmldoc/html.h (+1 lines)
Lines 309-314 Link Here
309
309
310
extern void	htmlSetBaseSize(float p, float s);
310
extern void	htmlSetBaseSize(float p, float s);
311
extern void	htmlSetCharSet(const char *cs);
311
extern void	htmlSetCharSet(const char *cs);
312
extern int	htmlSetMetaCharSet(tree_t *tree);
312
extern void	htmlSetTextColor(uchar *color);
313
extern void	htmlSetTextColor(uchar *color);
313
314
314
extern void	htmlDebugStats(const char *title, tree_t *t);
315
extern void	htmlDebugStats(const char *title, tree_t *t);
(-)htmldoc-1.8.23.orig/htmldoc/htmllib.cxx (+67 lines)
Lines 1854-1859 Link Here
1854
  return (NULL);
1854
  return (NULL);
1855
}
1855
}
1856
1856
1857
/*
1858
 * 'htmlGetMetaCharSet()' - Get document charset from "meta" data...
1859
 */
1860
1861
int
1862
htmlSetMetaCharSet(tree_t *tree)	/* I - Document tree */
1863
{
1864
  uchar	*tname,			/* Name value from tree entry */
1865
	*tcontent,		/* Content value from tree entry */
1866
	*tchar, *tchar2;
1867
  uchar charset[256];
1868
1869
  while (tree != NULL)
1870
  {
1871
   /*
1872
    * Check this tree entry...
1873
    */
1874
    if (tree->markup == MARKUP_META)
1875
    {
1876
      if ((tname = htmlGetVariable(tree, (uchar *)"HTTP-EQUIV")) != NULL &&
1877
          (tcontent = htmlGetVariable(tree, (uchar *)"CONTENT")) != NULL)
1878
	if (strcasecmp((char *)tname, "Content-Type") == 0)
1879
	  if ((tchar = (uchar *)strstr((char *)tcontent, "charset=")) != NULL ||
1880
	      (tchar = (uchar *)strstr((char *)tcontent, "CHARSET=")) != NULL)
1881
	  {
1882
1883
	    tchar += 8;
1884
	    for (tchar2 = charset; (*tchar >= (uchar)'a' && *tchar <= (uchar)'z') ||
1885
	                           (*tchar >= (uchar)'A' && *tchar <= (uchar)'Z') ||
1886
	                           (*tchar >= (uchar)'0' && *tchar <= (uchar)'9') ||
1887
			           *tchar == (uchar)'_' || *tchar == (uchar)'-';)
1888
	      *tchar2++ = *tchar++;
1889
	    *tchar2 = (uchar)'\0';
1890
	    for (tchar2 = charset; *tchar2 != (uchar)'\0'; tchar2++)
1891
	      *tchar2 = (uchar)tolower((char)*tchar2);
1892
	    htmlSetCharSet((char *)charset);
1893
	    return 1;
1894
	  }
1895
      if ((tname = htmlGetVariable(tree, (uchar *)"CHARSET")) != NULL)
1896
      {
1897
        tchar = tname;
1898
	for (tchar2 = charset; *tchar != (uchar)'\0';)
1899
	  *tchar2++ = (uchar)tolower((char)*tchar++);
1900
	*tchar2 = (uchar)'\0';
1901
	htmlSetCharSet((char *)charset);
1902
	return 1;
1903
      }
1904
    }
1905
1906
   /*
1907
    * Check child entries...
1908
    */
1909
1910
    if (tree->child != NULL)
1911
      if (htmlSetMetaCharSet(tree->child))
1912
        return 1;
1913
1914
   /*
1915
    * Next tree entry...
1916
    */
1917
1918
    tree = tree->next;
1919
  }
1920
1921
  return 0;
1922
}
1923
1857
1924
1858
/*
1925
/*
1859
 * 'htmlGetStyle()' - Get a style value from a node's STYLE attribute.
1926
 * 'htmlGetStyle()' - Get a style value from a node's STYLE attribute.

Return to bug 8196