Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/0922/5

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Add string+number.
 [rsc] --rw-rw-r-- M 191333 glenda sys 4389 Sep 22 08:47 sys/src/cmd/acid/acid.h
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/acid/acid.h:232,237 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/acid/acid.h:232,238
	  int	scmp(String*, String*);
	  void	sproc(int);
	  String*	stradd(String*, String*);
	+ String*	straddrune(String*, Rune);
	  String*	strnode(char*);
	  String*	strnodlen(char*, int);
	  char*	system(void);
 [rsc] --rw-rw-r-- M 191333 glenda sys 15220 Sep 22 08:48 sys/src/cmd/acid/expr.c
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/acid/expr.c:362,367 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/acid/expr.c:362,373
	  			res->string = stradd(l.string, r.string); 
	  			break;
	  		}
	+ 		if(r.type == TINT) {
	+ 			res->type = TSTRING;
	+ 			res->fmt = 's';
	+ 			res->string = straddrune(l.string, r.ival);
	+ 			break;
	+ 		}
	  		error("bad rhs for +");
	  	case TLIST:
	  		res->type = TLIST;
 [rsc] --rw-rw-r-- M 191333 glenda sys 4616 Sep 22 08:47 sys/src/cmd/acid/util.c
	/n/sourcesdump/2005/0922/plan9/sys/src/cmd/acid/util.c:267,272 - 
	/n/sourcesdump/2005/0923/plan9/sys/src/cmd/acid/util.c:267,290
	  	return s;
	  }
	  
	+ String*
	+ straddrune(String *l, Rune r)
	+ {
	+ 	int len;
	+ 	String *s;
	+ 
	+ 	len = l->len+runelen(r);
	+ 	s = gmalloc(sizeof(String)+len+1);
	+ 	s->gclink = gcl;
	+ 	gcl = s;
	+ 	s->len = len;
	+ 	s->string = (char*)s+sizeof(String);
	+ 	memmove(s->string, l->string, l->len);
	+ 	runetochar(s->string+l->len, &r);
	+ 	s->string[s->len] = 0;
	+ 	return s;
	+ }
	+ 
	  int
	  scmp(String *sr, String *sl)
	  {
 [rsc] --rw-rw-r-- M 191333 glenda sys 65062 Sep 22 13:46 sys/doc/acid.ms
	/n/sourcesdump/2005/0922/plan9/sys/doc/acid.ms:807,814 - 
	/n/sourcesdump/2005/0923/plan9/sys/doc/acid.ms:807,816
	  .I string
	  or
	  .I list
	- type  then addition is defined as concatenation. Subtraction is undefined for
	- these two types.
	+ type then addition is defined as concatenation. 
	+ Adding a string and an integer is treated as concatenation
	+ with the Unicode character corresponding to the integer.
	+ Subtraction is undefined for strings and lists.
	  .DS
	  	shift-expression:
	  		additive-expression
 [sys] --rwxrwxr-x M 191333 rsc sys 390487 Sep 22 23:10 386/bin/acid
	/sys/src/cmd/acid/expr.c:oadd
	/sys/src/cmd/acid/lex.c:yylex
	/sys/src/cmd/acid/util.c:straddrune


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].