Tcl Source Code

Check-in [2191bd8485]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make DEFAULT_TRIM_SET a MODULE_SCOPE string constant, so its value can be shared in tclCmdMZ.o and TclCompCmdsSZ.o and it no longer pollutes the tclStringTrim.h header file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2191bd84856ce684d6a0978a3a8e6b3cf539ba34
User & Date: jan.nijtmans 2014-01-08 11:04:44
References
2014-01-07
15:29
Revert Makefile.in changes and remove added tclStringTrim.h header. Otherwise, the same changes wo... Closed-Leaf check-in: acd990a59d user: jan.nijtmans tags: remove-trim-header
Context
2014-01-21
17:25
[2992970] Restore safety of Tcl_AppendObjToObj(x, x) for bytearrays. check-in: 704897a19b user: dgp tags: trunk
2014-01-15
19:04
[2992970] Restore the safety of Tcl_AppendObjToObj(x, x) for bytearrays. Also moves overflow checkin... Closed-Leaf check-in: e5267e9dcd user: dgp tags: bug-2992970
2014-01-09
14:29
merge trunk check-in: 769d84f6a6 user: dgp tags: dgp-refactor
2014-01-08
11:04
Make DEFAULT_TRIM_SET a MODULE_SCOPE string constant, so its value can be shared in tclCmdMZ.o and T... check-in: 2191bd8485 user: jan.nijtmans tags: trunk
2014-01-07
14:19
Add compilations for the following commands: * concat * linsert * namespace origin * next * str... check-in: 4492d3b645 user: dkf tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tclCmdMZ.c.

    28     28   			    int result);
    29     29   static int		TryPostFinal(ClientData data[], Tcl_Interp *interp,
    30     30   			    int result);
    31     31   static int		TryPostHandler(ClientData data[], Tcl_Interp *interp,
    32     32   			    int result);
    33     33   static int		UniCharIsAscii(int character);
    34     34   static int		UniCharIsHexDigit(int character);
           35  +
           36  +/*
           37  + * Default set of characters to trim in [string trim] and friends. This is a
           38  + * UTF-8 literal string containing all Unicode space characters [TIP #413]
           39  + */
           40  +
           41  +const char tclDefaultTrimSet[] = 
           42  +	"\x09\x0a\x0b\x0c\x0d " /* ASCII */
           43  +	"\xc0\x80" /*     nul (U+0000) */
           44  +	"\xc2\x85" /*     next line (U+0085) */
           45  +	"\xc2\xa0" /*     non-breaking space (U+00a0) */
           46  +	"\xe1\x9a\x80" /* ogham space mark (U+1680) */
           47  +	"\xe1\xa0\x8e" /* mongolian vowel separator (U+180e) */
           48  +	"\xe2\x80\x80" /* en quad (U+2000) */
           49  +	"\xe2\x80\x81" /* em quad (U+2001) */
           50  +	"\xe2\x80\x82" /* en space (U+2002) */
           51  +	"\xe2\x80\x83" /* em space (U+2003) */
           52  +	"\xe2\x80\x84" /* three-per-em space (U+2004) */
           53  +	"\xe2\x80\x85" /* four-per-em space (U+2005) */
           54  +	"\xe2\x80\x86" /* six-per-em space (U+2006) */
           55  +	"\xe2\x80\x87" /* figure space (U+2007) */
           56  +	"\xe2\x80\x88" /* punctuation space (U+2008) */
           57  +	"\xe2\x80\x89" /* thin space (U+2009) */
           58  +	"\xe2\x80\x8a" /* hair space (U+200a) */
           59  +	"\xe2\x80\x8b" /* zero width space (U+200b) */
           60  +	"\xe2\x80\xa8" /* line separator (U+2028) */
           61  +	"\xe2\x80\xa9" /* paragraph separator (U+2029) */
           62  +	"\xe2\x80\xaf" /* narrow no-break space (U+202f) */
           63  +	"\xe2\x81\x9f" /* medium mathematical space (U+205f) */
           64  +	"\xe2\x81\xa0" /* word joiner (U+2060) */
           65  +	"\xe3\x80\x80" /* ideographic space (U+3000) */
           66  +	"\xef\xbb\xbf" /* zero width no-break space (U+feff) */
           67  +;
    35     68   
    36     69   /*
    37     70    *----------------------------------------------------------------------
    38     71    *
    39     72    * Tcl_PwdObjCmd --
    40     73    *
    41     74    *	This procedure is invoked to process the "pwd" Tcl command. See the
................................................................................
  3154   3187   {
  3155   3188       const char *string1, *string2;
  3156   3189       int triml, trimr, length1, length2;
  3157   3190   
  3158   3191       if (objc == 3) {
  3159   3192   	string2 = TclGetStringFromObj(objv[2], &length2);
  3160   3193       } else if (objc == 2) {
  3161         -	string2 = DEFAULT_TRIM_SET;
  3162         -	length2 = strlen(DEFAULT_TRIM_SET);
         3194  +	string2 = tclDefaultTrimSet;
         3195  +	length2 = strlen(tclDefaultTrimSet);
  3163   3196       } else {
  3164   3197   	Tcl_WrongNumArgs(interp, 1, objv, "string ?chars?");
  3165   3198   	return TCL_ERROR;
  3166   3199       }
  3167   3200       string1 = TclGetStringFromObj(objv[1], &length1);
  3168   3201   
  3169   3202       triml = TclTrimLeft(string1, length1, string2, length2);
................................................................................
  3202   3235   {
  3203   3236       const char *string1, *string2;
  3204   3237       int trim, length1, length2;
  3205   3238   
  3206   3239       if (objc == 3) {
  3207   3240   	string2 = TclGetStringFromObj(objv[2], &length2);
  3208   3241       } else if (objc == 2) {
  3209         -	string2 = DEFAULT_TRIM_SET;
  3210         -	length2 = strlen(DEFAULT_TRIM_SET);
         3242  +	string2 = tclDefaultTrimSet;
         3243  +	length2 = strlen(tclDefaultTrimSet);
  3211   3244       } else {
  3212   3245   	Tcl_WrongNumArgs(interp, 1, objv, "string ?chars?");
  3213   3246   	return TCL_ERROR;
  3214   3247       }
  3215   3248       string1 = TclGetStringFromObj(objv[1], &length1);
  3216   3249   
  3217   3250       trim = TclTrimLeft(string1, length1, string2, length2);
................................................................................
  3248   3281   {
  3249   3282       const char *string1, *string2;
  3250   3283       int trim, length1, length2;
  3251   3284   
  3252   3285       if (objc == 3) {
  3253   3286   	string2 = TclGetStringFromObj(objv[2], &length2);
  3254   3287       } else if (objc == 2) {
  3255         -	string2 = DEFAULT_TRIM_SET;
  3256         -	length2 = strlen(DEFAULT_TRIM_SET);
         3288  +	string2 = tclDefaultTrimSet;
         3289  +	length2 = strlen(tclDefaultTrimSet);
  3257   3290       } else {
  3258   3291   	Tcl_WrongNumArgs(interp, 1, objv, "string ?chars?");
  3259   3292   	return TCL_ERROR;
  3260   3293       }
  3261   3294       string1 = TclGetStringFromObj(objv[1], &length1);
  3262   3295   
  3263   3296       trim = TclTrimRight(string1, length1, string2, length2);

Changes to generic/tclCompCmdsSZ.c.

   806    806   
   807    807       tokenPtr = TokenAfter(parsePtr->tokenPtr);
   808    808       CompileWord(envPtr, tokenPtr,			interp, 1);
   809    809       if (parsePtr->numWords == 3) {
   810    810   	tokenPtr = TokenAfter(tokenPtr);
   811    811   	CompileWord(envPtr, tokenPtr,			interp, 2);
   812    812       } else {
   813         -	PushLiteral(envPtr, DEFAULT_TRIM_SET, strlen(DEFAULT_TRIM_SET));
          813  +	PushLiteral(envPtr, tclDefaultTrimSet, strlen(tclDefaultTrimSet));
   814    814       }
   815    815       OP(			STR_TRIM_LEFT);
   816    816       return TCL_OK;
   817    817   }
   818    818   
   819    819   int
   820    820   TclCompileStringTrimRCmd(
................................................................................
   834    834   
   835    835       tokenPtr = TokenAfter(parsePtr->tokenPtr);
   836    836       CompileWord(envPtr, tokenPtr,			interp, 1);
   837    837       if (parsePtr->numWords == 3) {
   838    838   	tokenPtr = TokenAfter(tokenPtr);
   839    839   	CompileWord(envPtr, tokenPtr,			interp, 2);
   840    840       } else {
   841         -	PushLiteral(envPtr, DEFAULT_TRIM_SET, strlen(DEFAULT_TRIM_SET));
          841  +	PushLiteral(envPtr, tclDefaultTrimSet, strlen(tclDefaultTrimSet));
   842    842       }
   843    843       OP(			STR_TRIM_RIGHT);
   844    844       return TCL_OK;
   845    845   }
   846    846   
   847    847   int
   848    848   TclCompileStringTrimCmd(
................................................................................
   862    862   
   863    863       tokenPtr = TokenAfter(parsePtr->tokenPtr);
   864    864       CompileWord(envPtr, tokenPtr,			interp, 1);
   865    865       if (parsePtr->numWords == 3) {
   866    866   	tokenPtr = TokenAfter(tokenPtr);
   867    867   	CompileWord(envPtr, tokenPtr,			interp, 2);
   868    868       } else {
   869         -	PushLiteral(envPtr, DEFAULT_TRIM_SET, strlen(DEFAULT_TRIM_SET));
          869  +	PushLiteral(envPtr, tclDefaultTrimSet, strlen(tclDefaultTrimSet));
   870    870       }
   871    871       OP(			STR_TRIM);
   872    872       return TCL_OK;
   873    873   }
   874    874   
   875    875   int
   876    876   TclCompileStringToUpperCmd(

Changes to generic/tclStringTrim.h.

    19     19   #define TCL_STRING_TRIM_H
    20     20   
    21     21   /*
    22     22    * Default set of characters to trim in [string trim] and friends. This is a
    23     23    * UTF-8 literal string containing all Unicode space characters. [TIP #413]
    24     24    */
    25     25   
    26         -#define DEFAULT_TRIM_SET \
    27         -	"\x09\x0a\x0b\x0c\x0d " /* ASCII */\
    28         -	"\xc0\x80" /*     nul (U+0000) */\
    29         -	"\xc2\x85" /*     next line (U+0085) */\
    30         -	"\xc2\xa0" /*     non-breaking space (U+00a0) */\
    31         -	"\xe1\x9a\x80" /* ogham space mark (U+1680) */ \
    32         -	"\xe1\xa0\x8e" /* mongolian vowel separator (U+180e) */\
    33         -	"\xe2\x80\x80" /* en quad (U+2000) */\
    34         -	"\xe2\x80\x81" /* em quad (U+2001) */\
    35         -	"\xe2\x80\x82" /* en space (U+2002) */\
    36         -	"\xe2\x80\x83" /* em space (U+2003) */\
    37         -	"\xe2\x80\x84" /* three-per-em space (U+2004) */\
    38         -	"\xe2\x80\x85" /* four-per-em space (U+2005) */\
    39         -	"\xe2\x80\x86" /* six-per-em space (U+2006) */\
    40         -	"\xe2\x80\x87" /* figure space (U+2007) */\
    41         -	"\xe2\x80\x88" /* punctuation space (U+2008) */\
    42         -	"\xe2\x80\x89" /* thin space (U+2009) */\
    43         -	"\xe2\x80\x8a" /* hair space (U+200a) */\
    44         -	"\xe2\x80\x8b" /* zero width space (U+200b) */\
    45         -	"\xe2\x80\xa8" /* line separator (U+2028) */\
    46         -	"\xe2\x80\xa9" /* paragraph separator (U+2029) */\
    47         -	"\xe2\x80\xaf" /* narrow no-break space (U+202f) */\
    48         -	"\xe2\x81\x9f" /* medium mathematical space (U+205f) */\
    49         -	"\xe2\x81\xa0" /* word joiner (U+2060) */\
    50         -	"\xe3\x80\x80" /* ideographic space (U+3000) */\
    51         -	"\xef\xbb\xbf" /* zero width no-break space (U+feff) */
           26  +MODULE_SCOPE const char tclDefaultTrimSet[];
    52     27   
    53     28   /*
    54     29    * The whitespace trimming set used when [concat]enating. This is a subset of
    55     30    * the above, and deliberately so.
    56     31    */
    57     32   
    58     33   #define CONCAT_TRIM_SET " \f\v\r\t\n"