home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 0 / 0979 / tcl.pat.vars < prev   
Encoding:
Internet Message Format  |  1990-12-28  |  4.6 KB

  1. From ficc%sugar!texbell!allspice.Berkeley.EDU!ouster Sat Mar  3 18:12:05 1990
  2. Received: by sugar.hackercorp.com (smail2.5)
  3.     id AA26093; 3 Mar 90 17:54:45 CST (Sat)
  4. Received: by sugar.hackercorp.com (smail2.5)
  5.     id AA19332; 3 Mar 90 01:11:29 CST (Sat)
  6. Received: by texbell (/\=-/\ Smail3.1.16.1 #16.6)
  7.     id <m0h4R8G-0000uOC@texbell>; Fri, 2 Mar 90 22:54 CST
  8. Posted-Date: Fri, 2 Mar 90 08:43:20 PST
  9. Received: from tyranny.Berkeley.EDU by cs.utexas.edu (5.59/1.50)
  10.     id AA10952; Fri, 2 Mar 90 10:45:46 CST
  11. Received: by sprite.Berkeley.EDU (5.59/1.29)
  12.     id AA412483; Fri, 2 Mar 90 08:43:20 PST
  13. Date: Fri, 2 Mar 90 08:43:20 PST
  14. From: ouster@allspice.Berkeley.EDU (John Ousterhout)
  15. Message-Id: <9003021643.AA412483@sprite.Berkeley.EDU>
  16. To: ficc!peter@uunet.uu.net
  17. Subject: Re: Variables fix
  18. Cc: peter@sugar.lonestar.org
  19. Status: O
  20.  
  21. I hope to have the non-existent-variable patches complete in the
  22. next week or two.  In case that's not soon enough for you, I'm
  23. returning a copy of your patches at the end of this message.
  24. >From ficc!peter@uunet.UU.NET Thu Feb 22 21:14:42 1990
  25. From: ficc!peter@uunet.UU.NET
  26. To: ouster@sprite.Berkeley.EDU
  27. Subject: Patches for empty variables.
  28. Cc: karl@uunet.UU.NET
  29. Date: Wed Feb 21 16:29:46 1990
  30.  
  31. The following patches let you differentiate between empty variables
  32. and non-existant ones.
  33.  
  34. *** old/tclBasic.c
  35. --- tcl/tclBasic.c
  36. ***************
  37. *** 686,692 ****
  38.                */
  39.       
  40.               value = Tcl_ParseVar(interp, src, &tmp);
  41. !             if (*value == 0) {
  42.                   result = TCL_ERROR;
  43.                   goto done;
  44.               }
  45. --- 686,692 ----
  46.                */
  47.       
  48.               value = Tcl_ParseVar(interp, src, &tmp);
  49. !             if (value == 0) {
  50.                   result = TCL_ERROR;
  51.                   goto done;
  52.               }
  53. ***************
  54. *** 1211,1216 ****
  55. --- 1211,1217 ----
  56.       char *buffer, *oldVar;
  57.   
  58.       oldVar = Tcl_GetVar(interp, "errorInfo", 1);
  59. +     if(!oldVar) oldVar = "";
  60.       length = strlen(oldVar);
  61.       buffer = (char *)malloc((unsigned) (length + strlen(message) + 1));
  62.       strcpy(buffer, oldVar);
  63. *** old/tclExpr.c
  64. --- tcl/tclExpr.c
  65. ***************
  66. *** 250,256 ****
  67.       case '$':
  68.           infoPtr->token = NUMBER;
  69.           var = Tcl_ParseVar(infoPtr->interp, p, &infoPtr->expr);
  70. !         if (*var == '\0') {
  71.           return TCL_ERROR;
  72.           }
  73.           if (((Interp *) infoPtr->interp)->noEval) {
  74. --- 250,256 ----
  75.       case '$':
  76.           infoPtr->token = NUMBER;
  77.           var = Tcl_ParseVar(infoPtr->interp, p, &infoPtr->expr);
  78. !         if (var == 0) {
  79.           return TCL_ERROR;
  80.           }
  81.           if (((Interp *) infoPtr->interp)->noEval) {
  82. *** old/tclProc.c
  83. --- tcl/tclProc.c
  84. ***************
  85. *** 158,164 ****
  86.    * Results:
  87.    *    The return value points to the current value of varName.  If
  88.    *    the variable is not defined in interp, either as a local or
  89. !  *    global variable, then a pointer to an empty string is returned.
  90.    *    Note:  the return value is only valid up until the next call to
  91.    *    Tcl_SetVar;  if you depend on the value lasting longer than that,
  92.    *    then make yourself a private copy.
  93. --- 158,165 ----
  94.    * Results:
  95.    *    The return value points to the current value of varName.  If
  96.    *    the variable is not defined in interp, either as a local or
  97. !  *    global variable, then a NULL pointer is returned.
  98. !  *
  99.    *    Note:  the return value is only valid up until the next call to
  100.    *    Tcl_SetVar;  if you depend on the value lasting longer than that,
  101.    *    then make yourself a private copy.
  102. ***************
  103. *** 185,191 ****
  104.       varPtr = FindVar(&iPtr->varFramePtr->varPtr, varName);
  105.       }
  106.       if (varPtr == NULL) {
  107. !     return "";
  108.       }
  109.       if (varPtr->flags & VAR_GLOBAL) {
  110.       varPtr = varPtr->globalPtr;
  111. --- 186,192 ----
  112.       varPtr = FindVar(&iPtr->varFramePtr->varPtr, varName);
  113.       }
  114.       if (varPtr == NULL) {
  115. !     return NULL;
  116.       }
  117.       if (varPtr->flags & VAR_GLOBAL) {
  118.       varPtr = varPtr->globalPtr;
  119. ***************
  120. *** 323,329 ****
  121.       c = *string;
  122.       *string = 0;
  123.       result = Tcl_GetVar(interp, name, 0);
  124. !     if (*result == '\0') {
  125.       Tcl_Return(interp, (char *) NULL, TCL_STATIC);
  126.       sprintf(interp->result, "couldn't find variable \"%.50s\"", name);
  127.       }
  128. --- 324,330 ----
  129.       c = *string;
  130.       *string = 0;
  131.       result = Tcl_GetVar(interp, name, 0);
  132. !     if (!result) {
  133.       Tcl_Return(interp, (char *) NULL, TCL_STATIC);
  134.       sprintf(interp->result, "couldn't find variable \"%.50s\"", name);
  135.       }
  136. ***************
  137. *** 360,366 ****
  138.       char *value;
  139.   
  140.       value = Tcl_GetVar(interp, argv[1], 0);
  141. !     if (*value == 0) {
  142.           sprintf(interp->result, "couldn't find variable \"%.50s\"",
  143.               argv[1]);
  144.           return TCL_ERROR;
  145. --- 361,367 ----
  146.       char *value;
  147.   
  148.       value = Tcl_GetVar(interp, argv[1], 0);
  149. !     if (value == 0) {
  150.           sprintf(interp->result, "couldn't find variable \"%.50s\"",
  151.               argv[1]);
  152.           return TCL_ERROR;
  153.  
  154.  
  155.