From 1998dd786e37685273ca97083ff52d0a409ba7aa Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Thu, 27 May 2004 21:14:59 +0200 Subject: [PATCH 1/8] backport bug#2708 fix from 4.1 --- myisam/ft_boolean_search.c | 2 +- myisam/ft_parser.c | 40 +++++++++++++++++++++--------------- mysql-test/r/fulltext.result | 3 +++ mysql-test/t/fulltext.test | 4 ++++ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 61381f80783..13f46849210 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -360,7 +360,7 @@ err: } -/* returns 1 if str0 ~= /\/ */ +/* returns 1 if str0 ~= /\bstr1\b/ */ static int _ftb_strstr(const byte *s0, const byte *e0, const byte *s1, const byte *e1, CHARSET_INFO *cs) diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c index f397660af6b..e40b7472113 100644 --- a/myisam/ft_parser.c +++ b/myisam/ft_parser.c @@ -124,27 +124,30 @@ byte ft_get_word(byte **start, byte *end, FT_WORD *word, FTB_PARAM *param) for (;docquot) { + if (*doc == FTB_RQUOT && param->quot) + { param->quot=doc; *start=doc+1; return 3; /* FTB_RBR */ } - if ((*doc == FTB_LBR || *doc == FTB_RBR || *doc == FTB_LQUOT) - && !param->quot) + if (!param->quot) { - /* param->prev=' '; */ - *start=doc+1; - if (*doc == FTB_LQUOT) param->quot=*start; - return (*doc == FTB_RBR)+2; - } - if (param->prev == ' ' && !param->quot) - { - if (*doc == FTB_YES ) { param->yesno=+1; continue; } else - if (*doc == FTB_EGAL) { param->yesno= 0; continue; } else - if (*doc == FTB_NO ) { param->yesno=-1; continue; } else - if (*doc == FTB_INC ) { param->plusminus++; continue; } else - if (*doc == FTB_DEC ) { param->plusminus--; continue; } else - if (*doc == FTB_NEG ) { param->pmsign=!param->pmsign; continue; } + if (*doc == FTB_LBR || *doc == FTB_RBR || *doc == FTB_LQUOT) + { + /* param->prev=' '; */ + *start=doc+1; + if (*doc == FTB_LQUOT) param->quot=*start; + return (*doc == FTB_RBR)+2; + } + if (param->prev == ' ') + { + if (*doc == FTB_YES ) { param->yesno=+1; continue; } else + if (*doc == FTB_EGAL) { param->yesno= 0; continue; } else + if (*doc == FTB_NO ) { param->yesno=-1; continue; } else + if (*doc == FTB_INC ) { param->plusminus++; continue; } else + if (*doc == FTB_DEC ) { param->plusminus--; continue; } else + if (*doc == FTB_NEG ) { param->pmsign=!param->pmsign; continue; } + } } param->prev=*doc; param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0); @@ -170,6 +173,11 @@ byte ft_get_word(byte **start, byte *end, FT_WORD *word, FTB_PARAM *param) return 1; } } + if (param->quot) + { + param->quot=*start=doc; + return 3; /* FTB_RBR */ + } return 0; } diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index baa3a834f6f..19bd355f537 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -122,6 +122,9 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B a b select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); a b +select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); +a b +Full-text search in MySQL implements vector space model select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE); a b Full-text search in MySQL implements vector space model diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 86d2cde370a..bd887bc63ee 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -57,6 +57,10 @@ select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); +# bug#2708, bug#3870 crash + +select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); + # boolean w/o index: select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE); From 1aa3b2c79e8ec5903a80f21226e6219ed60f2a9d Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 27 May 2004 22:53:36 +0300 Subject: [PATCH 2/8] removed reference to not existing library lib_release\dbug.lib --- VC++Files/comp_err/comp_err.dsp | 2 +- VC++Files/sql/mysqld.dsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VC++Files/comp_err/comp_err.dsp b/VC++Files/comp_err/comp_err.dsp index f35e69a7884..cd9910698bf 100644 --- a/VC++Files/comp_err/comp_err.dsp +++ b/VC++Files/comp_err/comp_err.dsp @@ -46,7 +46,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\lib_release\mysys.lib wsock32.lib ..\lib_release\strings.lib ..\lib_release\dbug.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC.lib" /out:"../client_release/comp-err.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\lib_release\mysys.lib wsock32.lib ..\lib_release\strings.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC.lib" /out:"../client_release/comp-err.exe" # Begin Target # Name "comp_err - Win32 Release" diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 6045188b29a..454b79abe43 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -110,7 +110,7 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\dbug.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /debug /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /debug /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\innodb.lib ..\lib_release\zlib.lib /nologo /subsystem:console /map /machine:I386 /out:"../client_release/mysqld-nt.exe" # SUBTRACT LINK32 /pdb:none /debug From 6cd8de36453cf24867a7d8b84e276fea9bed55ad Mon Sep 17 00:00:00 2001 From: "jani@a80-186-24-72.elisa-laajakaista.fi" <> Date: Thu, 27 May 2004 23:39:50 +0300 Subject: [PATCH 3/8] Merged in some patches from Novell. --- netware/BUILD/nwbootstrap | 5 ++ netware/mysqld_safe.c | 108 ++++++++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/netware/BUILD/nwbootstrap b/netware/BUILD/nwbootstrap index f54775bf054..ba6d34bddc8 100755 --- a/netware/BUILD/nwbootstrap +++ b/netware/BUILD/nwbootstrap @@ -171,6 +171,11 @@ do rm $file.org done +# create the libmysql.imp file in netware folder from libmysql/libmysql.def +# file +echo "generating llibmysql.imp file..." +awk 'BEGIN{x=0;} x==1 {print $1;next} /EXPORTS/{x=1}' libmysql/libmysql.def > netware/libmysql.imp + # build linux tools echo "compiling linux tools..." ./netware/BUILD/compile-linux-tools diff --git a/netware/mysqld_safe.c b/netware/mysqld_safe.c index a815497ac0f..8d4a5c4a296 100644 --- a/netware/mysqld_safe.c +++ b/netware/mysqld_safe.c @@ -67,6 +67,7 @@ void check_data_vol(); void check_setup(); void check_tables(); void mysql_start(int, char*[]); +void parse_setvar(char *arg); /****************************************************************************** @@ -321,7 +322,8 @@ void parse_args(int argc, char *argv[]) OPT_ERR_LOG, OPT_SAFE_LOG, OPT_MYSQLD, - OPT_HELP + OPT_HELP, + OPT_SETVAR }; static struct option options[] = @@ -337,6 +339,7 @@ void parse_args(int argc, char *argv[]) {"safe-log", required_argument, 0, OPT_SAFE_LOG}, {"mysqld", required_argument, 0, OPT_MYSQLD}, {"help", no_argument, 0, OPT_HELP}, + {"set-variable", required_argument, 0, OPT_SETVAR}, {0, 0, 0, 0} }; @@ -384,7 +387,11 @@ void parse_args(int argc, char *argv[]) case OPT_MYSQLD: strcpy(mysqld, optarg); break; - + + case OPT_SETVAR: + parse_setvar(optarg); + break; + case OPT_HELP: usage(); break; @@ -396,6 +403,25 @@ void parse_args(int argc, char *argv[]) } } +/* + parse_setvar(char *arg) + Pasrsing for port just to display the port num on the mysqld_safe screen +*/ +void parse_setvar(char *arg) +{ + char *pos; + + if ((pos= strindex(arg, "port"))) + { + for (; *pos && *pos != '='; pos++) ; + if (*pos) + strcpy(port, pos + 1); + } +} +/****************************************************************************** + + + /****************************************************************************** get_options() @@ -599,32 +625,32 @@ void check_tables() ******************************************************************************/ void mysql_start(int argc, char *argv[]) { - arg_list_t al; - int i, j, err; - struct stat info; - time_t cal; - struct tm lt; - char stamp[PATH_MAX]; - char skip; + arg_list_t al; + int i, j, err; + struct stat info; + time_t cal; + struct tm lt; + char stamp[PATH_MAX]; + char skip; // private options static char *private_options[] = { - "--autoclose", + "--autoclose", "--check-tables", "--help", - "--err-log=", - "--mysqld=", - NULL + "--err-log=", + "--mysqld=", + NULL }; - // args - init_args(&al); - add_arg(&al, "%s", mysqld); - - // parent args - for(i = 1; i < argc; i++) - { + // args + init_args(&al); + add_arg(&al, "%s", mysqld); + + // parent args + for(i = 1; i < argc; i++) + { skip = FALSE; // skip private arguments @@ -633,38 +659,42 @@ void mysql_start(int argc, char *argv[]) if(!strnicmp(argv[i], private_options[j], strlen(private_options[j]))) { skip = TRUE; + consoleprintf("The argument skipped is %s\n",argv[i]); break; } } - - if (!skip) add_arg(&al, "%s", argv[i]); - } - + + if (!skip) + { + add_arg(&al, "%s", argv[i]); + consoleprintf("The final argument is %s\n",argv[i]); + } + } // spawn - do - { - // check the database tables - if (checktables) check_tables(); - - // status + do + { + // check the database tables + if (checktables) check_tables(); + + // status time(&cal); localtime_r(&cal, <); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", <); log("mysql started : %s\n", stamp); - - // spawn mysqld - spawn(mysqld, &al, TRUE, NULL, NULL, err_log); - } - while (!stat(pid_file, &info)); - - // status + + // spawn mysqld + spawn(mysqld, &al, TRUE, NULL, NULL, err_log); + } + while (!stat(pid_file, &info)); + + // status time(&cal); localtime_r(&cal, <); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", <); log("mysql stopped : %s\n\n", stamp); - // free args - free_args(&al); + // free args + free_args(&al); } /****************************************************************************** From 518019f511ae292db9c0b1ee98fa7b96270e3e9c Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 May 2004 00:03:19 +0300 Subject: [PATCH 4/8] Remove some code from sql_yacc.cc that doesn't do anything except produce warnings on VC++ --- mysql-test/t/fulltext.test | 4 ---- scripts/make_win_src_distribution.sh | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index b67997e640b..91e81c5dbe0 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -69,10 +69,6 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); -# bug#2708 crash - -select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); - # bug#2708, bug#3870 crash select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 68ba488f3d5..f6102085021 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -302,10 +302,12 @@ do done # -# Fix some windows files +# Fix some windows files to avoid compiler warnings # -./extra/replace std:: "" -- $BASE/sql/sql_yacc.cpp +./extra/replace std:: "" < $BASE/sql/sql_yacc.cpp | sed '/^ *switch (yytype)$/ { N; /\n *{$/ { N; /\n *default:$/ { N; /\n *break;$/ { N; /\n *}$/ d; };};};} ' > $BASE/sql/sql_yacc.cpp-new +mv $BASE/sql/sql_yacc.cpp-new $BASE/sql/sql_yacc.cpp + unix_to_dos $BASE/README mv $BASE/README $BASE/README.txt From a7c17eee46b6568507b3e6ba6038ae5368eb3f44 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 May 2004 00:32:55 +0300 Subject: [PATCH 5/8] Portability fix for 32 bit file systems --- mysql-test/r/variables.result | 2 +- mysql-test/t/variables.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index f84364089bc..e36f4165f46 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -380,4 +380,4 @@ Variable 'key_buffer_size' is a GLOBAL variable set global myisam_max_sort_file_size=4294967296; show global variables like 'myisam_max_sort_file_size'; Variable_name Value -myisam_max_sort_file_size 4294967296 +myisam_max_sort_file_size MAX_FILE_SIZE diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index e59667d6af4..b9aa52ec627 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -274,4 +274,5 @@ select @@session.key_buffer_size; # expected: check that there is no overflow when 64-bit unsigned # variables are set set global myisam_max_sort_file_size=4294967296; +--replace_result 4294967296 MAX_FILE_SIZE 2146435072 MAX_FILE_SIZE show global variables like 'myisam_max_sort_file_size'; From 47cc3af0e9b10ef3d6006bf02b403e0229ab7ddb Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 May 2004 01:02:20 +0300 Subject: [PATCH 6/8] Always enable HAVE_COMPRESS on netware --- include/config-netware.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/config-netware.h b/include/config-netware.h index c4e63056353..3e145f566a1 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -57,6 +57,10 @@ extern "C" { #undef HAVE_CRYPT #endif /* HAVE_OPENSSL */ +/* Configure can't detect this because it uses AC_TRY_RUN */ +#undef HAVE_COMPRESS +#define HAVE_COMPRESS + /* include the old function apis */ #define USE_OLD_FUNCTIONS 1 From 33dcccb5bfa027440f9e8ed06cc342bced9041e0 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 May 2004 02:00:34 +0300 Subject: [PATCH 7/8] Portability fix for HPUX --- configure.in | 3 +++ innobase/os/os0file.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 29a887076ac..f2b66d1e09d 100644 --- a/configure.in +++ b/configure.in @@ -2484,6 +2484,9 @@ AC_SUBST(netware_dir) AC_SUBST(linked_netware_sources) AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware") +# Ensure that table handlers gets all modifications to CFLAGS/CXXFLAGS +export CC CXX CFLAGS CXXFLAGS LD LDFLAGS AR + if test "$with_server" = "yes" -o "$THREAD_SAFE_CLIENT" != "no" then AC_DEFINE(THREAD) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 81566337218..681c4e487e7 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1111,7 +1111,7 @@ os_file_pread( os_n_file_reads++; -#ifdef HAVE_PREAD +#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD) os_mutex_enter(os_file_count_mutex); os_file_n_pending_preads++; os_mutex_exit(os_file_count_mutex); @@ -1186,7 +1186,7 @@ os_file_pwrite( os_n_file_writes++; -#ifdef HAVE_PWRITE +#if defined(HAVE_PWRITE) && !defined(HAVE_BROKEN_PREAD) os_mutex_enter(os_file_count_mutex); os_file_n_pending_pwrites++; os_mutex_exit(os_file_count_mutex); From ccc4171276b3712a82fd387adf3803010216bd4f Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 28 May 2004 02:36:43 +0300 Subject: [PATCH 8/8] Portability fix (using 'char' as argument to C functions may give warnings) --- include/m_string.h | 2 +- mysql-test/r/variables.result | 1 + strings/int2str.c | 41 ++++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index 27da759f2c7..7fc35dc2e48 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -225,7 +225,7 @@ extern long strtol(const char *str, char **ptr, int base); extern ulong strtoul(const char *str, char **ptr, int base); #endif -extern char *int2str(long val, char *dst, int radix, char upcase); +extern char *int2str(long val, char *dst, int radix, int upcase); extern char *int10_to_str(long val,char *dst,int radix); extern char *str2int(const char *src,int radix,long lower,long upper, long *val); diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index fbd9664ba9d..cd86c69d8f0 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -385,6 +385,7 @@ select 1; 1 1 select @@session.key_buffer_size; +ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable set ft_boolean_syntax = @@init_connect; ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL set global ft_boolean_syntax = @@init_connect; diff --git a/strings/int2str.c b/strings/int2str.c index 39b38ef3e1b..be86e9735ab 100644 --- a/strings/int2str.c +++ b/strings/int2str.c @@ -34,7 +34,7 @@ char NEAR _dig_vec_lower[] = val - value to convert dst - points to buffer where string representation should be stored radix - radix of scale of notation - upcase - flag indicating that whenever we should use upper-case digits + upcase - set to 1 if we should use upper-case digits DESCRIPTION Converts the (long) integer value to its character form and moves it to @@ -52,34 +52,39 @@ char NEAR _dig_vec_lower[] = char * int2str(register long int val, register char *dst, register int radix, - char upcase) + int upcase) { char buffer[65]; register char *p; long int new_val; char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower; - if (radix < 0) { - if (radix < -36 || radix > -2) return NullS; - if (val < 0) { + if (radix < 0) + { + if (radix < -36 || radix > -2) + return NullS; + if (val < 0) + { *dst++ = '-'; val = -val; } radix = -radix; - } else { - if (radix > 36 || radix < 2) return NullS; } - /* The slightly contorted code which follows is due to the - fact that few machines directly support unsigned long / and %. - Certainly the VAX C compiler generates a subroutine call. In - the interests of efficiency (hollow laugh) I let this happen - for the first digit only; after that "val" will be in range so - that signed integer division will do. Sorry 'bout that. - CHECK THE CODE PRODUCED BY YOUR C COMPILER. The first % and / - should be unsigned, the second % and / signed, but C compilers - tend to be extraordinarily sensitive to minor details of style. - This works on a VAX, that's all I claim for it. - */ + else if (radix > 36 || radix < 2) + return NullS; + + /* + The slightly contorted code which follows is due to the fact that + few machines directly support unsigned long / and %. Certainly + the VAX C compiler generates a subroutine call. In the interests + of efficiency (hollow laugh) I let this happen for the first digit + only; after that "val" will be in range so that signed integer + division will do. Sorry 'bout that. CHECK THE CODE PRODUCED BY + YOUR C COMPILER. The first % and / should be unsigned, the second + % and / signed, but C compilers tend to be extraordinarily + sensitive to minor details of style. This works on a VAX, that's + all I claim for it. + */ p = &buffer[sizeof(buffer)-1]; *p = '\0'; new_val=(ulong) val / (ulong) radix;