X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fset.q;h=8d9afd61cf455776a12992a7ae2327d9d96e6cc2;hb=bc2466a1677cc97a837a75439b3d4c3b49a8125a;hp=e9f3ddedee4965517acdd222a42e1ae82a976d2c;hpb=74a57f26f1458b28a0fddbb9f46004ac8f4d9c30;p=pspp-builds.git diff --git a/src/set.q b/src/set.q index e9f3dded..8d9afd61 100644 --- a/src/set.q +++ b/src/set.q @@ -60,7 +60,7 @@ #include #include "settings.h" -#include +#include "error.h" #include #include #include @@ -985,11 +985,8 @@ set_viewport(int sig_num UNUSED) static char term_buffer[16384]; #endif - /* Workable defaults before we determine the real terminal size. */ - set_viewwidth = 79; - set_viewlength = 24; - - + set_viewwidth = -1; + set_viewlength = -1; #if __DJGPP__ || __BORLANDC__ { @@ -1007,7 +1004,7 @@ set_viewport(int sig_num UNUSED) /* This code stolen from termcap.info, though modified. */ termtype = getenv ("TERM"); if (!termtype) - msg (FE, _("Specify a terminal type with `setenv TERM '.")); + msg (FE, _("Specify a terminal type with the TERM environment variable.")); success = tgetent (term_buffer, termtype); if (success <= 0) @@ -1019,22 +1016,36 @@ set_viewport(int sig_num UNUSED) } else { - set_viewlength = tgetnum ("li"); - set_viewwidth = tgetnum ("co") - 1; + /* NOTE: Do not rely upon tgetnum returning -1 if the value is + not available. It's supposed to do it, but not all platforms + do (eg Cygwin) . + */ + if ( -1 != tgetnum("li")) + set_viewlength = tgetnum ("li"); + + if ( -1 != tgetnum("co")) + set_viewwidth = tgetnum ("co") - 1; } } -#else - { - char *s; +#endif /* HAVE_LIBTERMCAP */ /* Try the environment variables */ - s = getenv("COLUMNS"); - if ( s ) set_viewwidth = atoi(s); + if ( -1 == set_viewwidth ) + { + char *s = getenv("COLUMNS"); + if ( s ) set_viewwidth = atoi(s); + } - s = getenv("LINES"); - if ( s ) set_viewlength = atoi(s); - } -#endif /* !HAVE_LIBTERMCAP */ + if ( -1 == set_viewwidth ) + { + char *s = getenv("LINES"); + if ( s ) set_viewlength = atoi(s); + } + + + /* Last resort. Use hard coded values */ + if ( 0 > set_viewwidth ) set_viewwidth = 79; + if ( 0 > set_viewlength ) set_viewlength = 24; } @@ -1323,6 +1334,56 @@ seed_is_set(unsigned long *seed) } +static int global_algorithm = ENHANCED; +static int cmd_algorithm = ENHANCED; +static int *algorithm = &global_algorithm; + +static int syntax = ENHANCED; + +/* Set the algorithm option globally */ +void +set_algorithm(int x) +{ + global_algorithm = x; +} + +/* Set the algorithm option for this command only */ +void +set_cmd_algorithm(int x) +{ + cmd_algorithm = x; + algorithm = &cmd_algorithm; +} + +/* Unset the algorithm option for this command */ +void +unset_cmd_algorithm(void) +{ + algorithm = &global_algorithm; +} + +/* Return the current algorithm setting */ +int +get_algorithm(void) +{ + return *algorithm; +} + +/* Set the syntax option */ +void +set_syntax(int x) +{ + syntax = x; +} + +/* Get the current syntax setting */ +int +get_syntax(void) +{ + return syntax; +} + + /* Local Variables: mode: c