Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions check/fixes.frm
Original file line number Diff line number Diff line change
Expand Up @@ -3864,6 +3864,89 @@ assert succeeded?
assert result("test1") =~ expr("f(i1,N1_?,N2_?,i4)^2")
assert result("test2") =~ expr("f(N1_?,N2_?,N3_?,N4_?)^2")
*--#] Issue615 :
*--#[ Issue631_1 :
#procedure foo(?a)
#message `toupper_(abc)'
#message `toupper_(a,b,c)'
#message `toupper_(`?a')'
#message `tolower_(ABC)'
#message `tolower_(A,B,C)'
#message `tolower_(`?a')'
#message `?a'
#endprocedure

#call foo(1,2,3,abc,a,b,c,ABC,A,B,C)
.end
assert succeeded?
assert stdout =~ exact_pattern(<<'EOF')
~~~ABC
~~~A,B,C
~~~1,2,3,ABC,A,B,C,ABC,A,B,C
~~~abc
~~~a,b,c
~~~1,2,3,abc,a,b,c,abc,a,b,c
~~~1,2,3,abc,a,b,c,ABC,A,B,C
EOF
*--#] Issue631_1 :
*--#[ Issue631_2 :
#-
#define MYTOUPPER(x,y) "toupper_(`~x',`~y')"
#procedure foo(x,y)
#message ``MYTOUPPER(`x',`y')''
#message `toupper_(`x',`y')'
#endprocedure
#call foo(a,b)
#message ``MYTOUPPER(c,d)''
.end
assert succeeded?
assert stdout =~ exact_pattern(<<'EOF')
~~~A,B
~~~A,B
~~~C,D
EOF
*--#] Issue631_2 :
*--#[ Issue631_3 :
#-
#define str "abcde"
#do i = 0,6
#message takeleft_(`str',`i') = `takeleft_(`str',`i')'
#message takeright_(`str',`i') = `takeright_(`str',`i')'
#message keepleft_(`str',`i') = `keepleft_(`str',`i')'
#message keepright_(`str',`i') = `keepright_(`str',`i')'
#enddo
.end
assert succeeded?
assert stdout =~ exact_pattern(<<'EOF')
~~~takeleft_(abcde,0) = abcde
~~~takeright_(abcde,0) = abcde
~~~keepleft_(abcde,0) =
~~~keepright_(abcde,0) =
~~~takeleft_(abcde,1) = bcde
~~~takeright_(abcde,1) = abcd
~~~keepleft_(abcde,1) = a
~~~keepright_(abcde,1) = e
~~~takeleft_(abcde,2) = cde
~~~takeright_(abcde,2) = abc
~~~keepleft_(abcde,2) = ab
~~~keepright_(abcde,2) = de
~~~takeleft_(abcde,3) = de
~~~takeright_(abcde,3) = ab
~~~keepleft_(abcde,3) = abc
~~~keepright_(abcde,3) = cde
~~~takeleft_(abcde,4) = e
~~~takeright_(abcde,4) = a
~~~keepleft_(abcde,4) = abcd
~~~keepright_(abcde,4) = bcde
~~~takeleft_(abcde,5) =
~~~takeright_(abcde,5) =
~~~keepleft_(abcde,5) = abcde
~~~keepright_(abcde,5) = abcde
~~~takeleft_(abcde,6) =
~~~takeright_(abcde,6) =
~~~keepleft_(abcde,6) = abcde
~~~keepright_(abcde,6) = abcde
EOF
*--#] Issue631_3 :
*--#[ Issue633 :
s x,y,z;
c f;
Expand Down
20 changes: 15 additions & 5 deletions doc/manual/prepro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,33 @@ \section{The preprocessor variables}
string value will be substituted.

\noindent Preprocessor variables can have arguments and thereby become
macro's. One should consult the description of the \#define~\ref{predefine}
macros. One should consult the description of the \#define~\ref{predefine}
instruction about the delayed substitution feature to avoid the value of
the preprocessor variables in the macro would be substituted immediately
during the definition. Hence proper use is
\begin{verbatim}
#define EXCHANGE(x,y) "Multiply replace_(`~x',`~y',`~y',`~x');"
\end{verbatim}

\noindent \FORM{} has the following built in macro's:
\noindent \FORM{} has the following built in macros:
\begin{description}
\item[TOLOWER\_(string)] in which the character string in the argument is
converted to lower case. After this it will become input.
\item[TOUPPER\_(string)] in which the character string in the argument is
converted to upper case. After this it will become input.
\end{description}
It is anticipated that some more macro's will become available to allow for
the editing of names of variables.
as well as macros which allow one to edit the names of variables,
\begin{description}
\item[KEEPLEFT\_(string,n)] keep only the first n characters of string.
After this it will become input.
\item[KEEPRIGHT\_(string,n)] keep only the last n characters of string.
After this it will become input.
\item[TAKELEFT\_(string,n)] remove the first n characters of string.
After this it will become input.
\item[TAKERIGHT\_(string,n)] remove the last n characters of string.
After this it will become input.
\end{description}
Note that these macro names are not case sensitive.

%--#] The preprocessor variables :
%--#[ Calculator :
Expand Down Expand Up @@ -700,7 +710,7 @@ \section{\#define}
is allowed. The parameters should be referred to inside a pair of `' as
with all preprocessor variables. A special feature is the socalled
delayed\index{delayed substitution}
substitution\index{substitution!delayed}. With macro's like the above the
substitution\index{substitution!delayed}. With macros like the above the
question is always {\sl when} a preprocessor variable will be substituted.
Take for instance
% THIS EXAMPLE IS PART OF THE TESTSUITE. CHANGES HERE SHOULD BE APPLIED THERE AS
Expand Down
14 changes: 7 additions & 7 deletions sources/pre.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,20 @@ UBYTE GetChar(int level)
if ( StrICmp(namebuf,(UBYTE *)"random_") == 0 ) {
UBYTE *ranvalue;
ranvalue = PreRandom(s);
PutPreVar(namebuf,ranvalue,(UBYTE *)"?a",1);
PutPreVar(namebuf,ranvalue,0,1);
M_free(ranvalue,"PreRandom");
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"tolower_") == 0 ) {
UBYTE *ss = s;
while ( *ss ) { *ss = (UBYTE)(tolower(*ss)); ss++; }
PutPreVar(namebuf,s,(UBYTE *)"?a",1);
PutPreVar(namebuf,s,0,1);
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"toupper_") == 0 ) {
UBYTE *ss = s;
while ( *ss ) { *ss = (UBYTE)(toupper(*ss)); ss++; }
PutPreVar(namebuf,s,(UBYTE *)"?a",1);
PutPreVar(namebuf,s,0,1);
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"takeleft_") == 0 ) {
Expand All @@ -358,7 +358,7 @@ UBYTE GetChar(int level)
if ( x > nsize ) x = nsize;
}
else x = 0;
PutPreVar(namebuf,s+x,(UBYTE *)"?a",1);
PutPreVar(namebuf,s+x,0,1);
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"takeright_") == 0 ) {
Expand All @@ -374,7 +374,7 @@ UBYTE GetChar(int level)
else x = 0;
x = nsize - x;
s[x] = 0;
PutPreVar(namebuf,s,(UBYTE *)"?a",1);
PutPreVar(namebuf,s,0,1);
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"keepleft_") == 0 ) {
Expand All @@ -389,7 +389,7 @@ UBYTE GetChar(int level)
}
else x = nsize;
s[x] = 0;
PutPreVar(namebuf,s,(UBYTE *)"?a",1);
PutPreVar(namebuf,s,0,1);
goto dostream;
}
else if ( StrICmp(namebuf,(UBYTE *)"keepright_") == 0 ) {
Expand All @@ -404,7 +404,7 @@ UBYTE GetChar(int level)
}
else x = nsize;
x = nsize-x;
PutPreVar(namebuf,s+x,(UBYTE *)"?a",1);
PutPreVar(namebuf,s+x,0,1);
goto dostream;
}
while ( *s ) {
Expand Down
14 changes: 7 additions & 7 deletions sources/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,18 +1191,18 @@ void StartVariables(void)
PutPreVar((UBYTE *)"VERSION_",(UBYTE *)STRINGIFY(MAJORVERSION),0,0);
PutPreVar((UBYTE *)"SUBVERSION_",(UBYTE *)STRINGIFY(MINORVERSION),0,0);
PutPreVar((UBYTE *)"DATE_",(UBYTE *)MakeDate(),0,0);
PutPreVar((UBYTE *)"random_",(UBYTE *)"________",(UBYTE *)"?a",0);
PutPreVar((UBYTE *)"random_",(UBYTE *)"________",0,0);
PutPreVar((UBYTE *)"optimminvar_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"optimmaxvar_",(UBYTE *)("0"),0,0);
PutPreVar(AM.oldnumextrasymbols,(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"optimvalue_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"optimscheme_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"tolower_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"toupper_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"takeleft_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"takeright_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"keepleft_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"keepright_",(UBYTE *)("0"),(UBYTE *)("?a"),0);
PutPreVar((UBYTE *)"tolower_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"toupper_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"takeleft_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"takeright_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"keepleft_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"keepright_",(UBYTE *)("0"),0,0);
PutPreVar((UBYTE *)"SYSTEMERROR_",(UBYTE *)("0"),0,0);
/*
Next are a few 'constants' for diagram generation
Expand Down