@@ -104,7 +104,8 @@ static int highbit PARM((unsigned long));
104
104
static void makeDirectCmap PARM ((void ));
105
105
static void useOtherVisual PARM ((XVisualInfo * , int ) );
106
106
static void parseResources PARM ((int , char * * ));
107
- static void parseCmdLine PARM ((int , char * * ));
107
+ static void parseOptions PARM ((const char * ) );
108
+ static void parseCmdLine PARM ((int , char * * , int ));
108
109
static void verifyArgs PARM ((void ));
109
110
static void printoption PARM ((const char * ) );
110
111
static void cmdSyntax PARM ((int ));
@@ -295,6 +296,7 @@ int main(int argc, char **argv)
295
296
preset = 0 ;
296
297
viewonly = 0 ;
297
298
dpiMult = 1 ;
299
+ isize_wide = isize_high = 0 ;
298
300
299
301
#ifdef ENABLE_FIXPIX_SMOOTH
300
302
do_fixpix_smooth = 0 ;
@@ -376,7 +378,8 @@ int main(int argc, char **argv)
376
378
377
379
/* handle user-specified resources and cmd-line arguments */
378
380
parseResources (argc ,argv );
379
- parseCmdLine (argc , argv );
381
+ parseOptions ( getenv ("XV_OPTIONS" ) );
382
+ parseCmdLine (argc , argv , 1 );
380
383
verifyArgs ();
381
384
#ifdef AUTO_EXPAND
382
385
Vdinit ();
@@ -1487,7 +1490,7 @@ static void parseResources(int argc, char **argv)
1487
1490
1488
1491
1489
1492
/*****************************************************/
1490
- static void parseCmdLine (int argc , char * * argv )
1493
+ static void parseCmdLine (int argc , char * * argv , int allow_file_names )
1491
1494
{
1492
1495
int i , oldi , not_in_first_half , pm ;
1493
1496
int hidpi ;
@@ -1501,6 +1504,12 @@ static void parseCmdLine(int argc, char **argv)
1501
1504
not_in_first_half = 0 ;
1502
1505
1503
1506
if (argv [i ][0 ] != '-' && argv [i ][0 ] != '+' ) {
1507
+
1508
+ if (!allow_file_names ) {
1509
+ fprintf (stderr , "Unexpected option '%s'\n" , argv [i ]);
1510
+ cmdSyntax (1 );
1511
+ }
1512
+
1504
1513
/* a file name. put it in list */
1505
1514
1506
1515
if (!nostat ) {
@@ -1708,6 +1717,31 @@ static void parseCmdLine(int argc, char **argv)
1708
1717
else if (!argcmp (argv [i ],"-ibg" ,3 ,0 ,& pm )) /* image bkgd color */
1709
1718
{ if (++ i < argc ) imagebgstr = argv [i ]; }
1710
1719
1720
+ else if (!argcmp (argv [i ],"-isize" ,4 ,0 ,& pm )) /* isize width x high */
1721
+ { if (++ i < argc ) {
1722
+ int parse_flags , parse_x , parse_y ;
1723
+ unsigned parse_w , parse_h ;
1724
+ parse_x = parse_y = 0 ;
1725
+ parse_w = parse_h = 0 ;
1726
+ parse_flags = XParseGeometry (argv [i ], & parse_x , & parse_y , & parse_w , & parse_h );
1727
+ if ((parse_flags & WidthValue ) != 0 ) {
1728
+ if (parse_w > 1000 ) {
1729
+ parse_w = 1000 ;
1730
+ fprintf (stderr , "Warning: reduced large -isize width\n" );
1731
+ }
1732
+ isize_wide = parse_w ;
1733
+ if ((parse_flags & HeightValue ) != 0 ) {
1734
+ if (parse_h > 1000 ) {
1735
+ parse_h = 1000 ;
1736
+ fprintf (stderr , "Warning: reduced large -isize height\n" );
1737
+ }
1738
+ isize_high = parse_h ;
1739
+ }
1740
+ if (isize_high == 0 ) isize_high = (isize_wide * 3 ) / 4 ;
1741
+ }
1742
+ }
1743
+ }
1744
+
1711
1745
else if (!argcmp (argv [i ],"-lbrowse" ,3 ,1 ,& browseMode )); /* browse mode */
1712
1746
1713
1747
else if (!argcmp (argv [i ],"-lo" ,3 ,0 ,& pm )) /* lowlight */
@@ -1862,11 +1896,82 @@ static void parseCmdLine(int argc, char **argv)
1862
1896
1863
1897
/* build origlist[], a copy of namelist that remains unmodified, for
1864
1898
use with the 'autoDelete' option */
1865
- orignumnames = numnames ;
1866
- xvbcopy ((char * ) namelist , (char * ) origlist , sizeof (origlist ));
1899
+ if (allow_file_names ) {
1900
+ orignumnames = numnames ;
1901
+ xvbcopy ((char * ) namelist , (char * ) origlist , sizeof (origlist ));
1902
+ }
1867
1903
}
1868
1904
1869
1905
1906
+ /*****************************************************/
1907
+ static void parseOptions (const char * options )
1908
+ {
1909
+ #define MAX_OPTIONS 1000
1910
+ char * option_list [ MAX_OPTIONS ];
1911
+ char * option_ptr , * out_ptr ;
1912
+ int option_len ;
1913
+ int num_options ;
1914
+ char quote ;
1915
+ static char * option_buf ; /* so asan doesn't warn about lost memory */
1916
+
1917
+ if (options == NULL || * options == '\0' ) {
1918
+ return ;
1919
+ }
1920
+
1921
+ /* fprintf(stderr, "options '%s'\n", options); */
1922
+
1923
+ option_len = strlen (options );
1924
+ option_buf = (char * ) malloc (option_len + 1 );
1925
+ if (!option_buf ) {
1926
+ FatalError ("can't malloc option buf\n" );
1927
+ }
1928
+ memcpy (option_buf , options , option_len + 1 );
1929
+ num_options = 0 ;
1930
+ option_list [ num_options ++ ] = NULL ;
1931
+ option_ptr = option_buf ;
1932
+ while (* option_ptr != '\0' && num_options < MAX_OPTIONS - 1 ) {
1933
+ while (* option_ptr == ' ' || * option_ptr == '\t' ) {
1934
+ option_ptr ++ ;
1935
+ }
1936
+ quote = * option_ptr ;
1937
+ if (quote == '\'' || quote == '"' ) {
1938
+ /* quoted option */
1939
+ /* very simple quoting to allow embedded spaces */
1940
+ option_ptr ++ ;
1941
+ option_list [ num_options ++ ] = option_ptr ;
1942
+ out_ptr = option_ptr ;
1943
+ while (* option_ptr != quote && * option_ptr != '\0' ) {
1944
+ if (* option_ptr == '\\' ) {
1945
+ option_ptr ++ ;
1946
+ if (* option_ptr == '\0' ) break ;
1947
+ }
1948
+ * out_ptr ++ = * option_ptr ++ ;
1949
+ }
1950
+ if (* option_ptr != '\0' ) {
1951
+ option_ptr ++ ;
1952
+ }
1953
+ * out_ptr = '\0' ;
1954
+ } else {
1955
+ /* unquoted option */
1956
+ option_list [ num_options ++ ] = option_ptr ;
1957
+ while (* option_ptr != ' ' && * option_ptr != '\t' && * option_ptr != '\0' ) {
1958
+ option_ptr ++ ;
1959
+ }
1960
+ if (* option_ptr != '\0' ) {
1961
+ * option_ptr = '\0' ;
1962
+ option_ptr ++ ;
1963
+ }
1964
+ }
1965
+ /* fprintf(stderr, "option %d '%s'\n", num_options-1, option_list[ num_options-1 ]); */
1966
+ }
1967
+
1968
+ option_list [ num_options ] = NULL ;
1969
+
1970
+ parseCmdLine (num_options , option_list , /* allow_file_names */ 0 );
1971
+
1972
+ /* option_buf can't be freed because parseCmdLine copies pointers to some arguments */
1973
+ }
1974
+
1870
1975
/*****************************************************************/
1871
1976
static void verifyArgs (void )
1872
1977
{
@@ -2017,6 +2122,7 @@ static void cmdSyntax(int i)
2017
2122
printoption ("[-dir directory]" );
2018
2123
printoption ("[-display disp]" );
2019
2124
printoption ("[-/+dither]" );
2125
+ printoption ("[-dpimult val]" );
2020
2126
printoption ("[-drift dx dy]" );
2021
2127
printoption ("[-expand exp | hexp:vexp]" );
2022
2128
printoption ("[-fg color]" );
@@ -2034,13 +2140,15 @@ static void cmdSyntax(int i)
2034
2140
printoption ("[-help]" );
2035
2141
printoption ("[-/+hflip]" );
2036
2142
printoption ("[-hi color]" );
2143
+ printoption ("[-/+hidpi]" );
2037
2144
printoption ("[-/+hist]" );
2038
2145
printoption ("[-/+hsv]" );
2039
2146
printoption ("[-ibg color]" ); /* GRR 19980314 */
2040
2147
printoption ("[-icgeometry geom]" );
2041
2148
printoption ("[-/+iconic]" );
2042
2149
printoption ("[-igeometry geom]" );
2043
2150
printoption ("[-/+imap]" );
2151
+ printoption ("[-isize geom]" );
2044
2152
printoption ("[-/+lbrowse]" );
2045
2153
printoption ("[-lo color]" );
2046
2154
printoption ("[-/+loadclear]" );
0 commit comments