I am working on an old Fortran code and the following syntax puzzled me:
102 FORMAT(' INPUTS ',/1H ,12('='),//
+' HERE THE SCORE '\\
+' WELL DONE')
I don't understand what are the backslashes doing? and like this it is not compiling, without the back slashes it is but I would like to understand and not just removing them.
Related
I am trying to run modsecurity CRS within Varnish (varnish-6.0.3) but I have a problem with the rules 932106, 932150, 932105 and 932100 -> RCE related. The VCC compiler is throwing the syntax error (for example [rule 932106]):
if(req.url ~ "(?:;|\{|\||\|\||&|&&|\n|\r|\$\(|\$\(\(|`|\${|<\(|>\(|\(\s*\))\s*(?:{|\s*\(\s*|\w+=(?:[^\s]*|\$.*|\$.*|<.*|>.*|\'.*\'|\".*\")\s+|!\s*|\$)*\s*(?:'|\")*(?:[\?\*\[\]\(\)\-\|+\w'\"\.\/\\\\]+\/)?[\\\\'\"]*(?:(?:(?:a[\\\\'\"]*p[\\\\'\"]*t[\\\\'\"]*i[\\\\'\"]*t[\\\\'\"]*u[\\\\'\"]*d|u[\\\\'\"]*p[\\\\'\"]*2[\\\\'\"]*d[\\\\'\"]*a[\\\\'\"]*t)[\\\\'\"]*e|d[\\\\'\"]*n[\\\\'\"]*f|v[\\\\'\"]*i)[\\\\'\"]*(?:\s|<|>).*|p[\\\\'\"]*(?:a[\\\\'\"]*c[\\\\'\"]*m[\\\\'\"]*a[\\\\'\"]*n[\\\\'\"]*(?:\s|<|>).*|w[\\\\'\"]*d|s)|w[\\\\'\"]*(?:(?:\s|<|>).*|h[\\\\'\"]*o))\b{
------------------------------------------------------------------------------------------------------------------------------------------#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
without any further explanation, which means the syntax error is within: \", this is kinda surprising as the " char is escaped.
Does anyone had similar issue in the past or have any idea how to solve it?
The regexes from the rulesets are not modified and are stable ones from CRS (v3.0).
I suggest you use long strings to reduce the risk of escaping issues.
This is what a long string looks like in Varnish:
{"Some string, including "double quotes""}
That way, you don't need to escape double quotes, and maybe that will solve your problem.
I'm trying to count the number of semicolon separated values in OBIEE.
I'm using the following formula: EVALUATE('REGEXP_COUNT(%1, '';'')', "Bibliographic Details"."Title") It returns an error:
When I try to use the same formula but change the '';'' with say ''a'' everything works as expected.
I don't recall semicolon being a saved character in REGEX so it's weird to me.
What I did eventually that gave me the required result:
EVALUATE('REGEXP_COUNT(%1, ''\;'')', "Bibliographic Details"."Title")
For some reason the "\" before the ";" fixed the problem.
Im confused as to where the errors in my syntax are occuring. I'm new to coding and am trying to learn but im lost here. the error is occuring after the
def fun2(n): during the if 0<=n: statement. if you would be kind to point out any other errors in my code it would be appreicated. for reference I am using python 2.7.9.
EDIT: I had forgotten about my established main function. that was the source of my syntax error due to my inner functions not being tabbed. Thank you to those who answered.
def main():
def fun(n):
func= (n**3)-1
def fun2(n):
for i in range(n):
if 0<=n:
func2 += i*fun(i)
if 0 > n:
func2 = 0
def fun3(m,n):
c3=[]
if m<=n:
C3.append[func2(n)]
if m>n:
c3=[]
Python is based on tabs and spaces, and you've got a line of code that is more intended than python would like it to be. Its not possible to see from your code above, but an IDE like pyCharm or a text editor like sublime text could help you out here.
Another thing to check is that you are consistently using tabs or consistently using spaces. Python doesn't like to mix the two, and even if you press only the tab key, sometimes your computer still puts in 4 or 5 spaces instead.
This is especially a problem if you copy and pasted some of the code from somewhere--who knows whether that pasted code used spaces or tabs?
I have a Fortran program in which I use a format staement for writing like
WRITE (12,'(A72,1X,A,1X,I6.6)') ALINE,SFFIX(1:NUM),LINENO
which works fine. However when I write a character string `fmtt' like
WRITE (fmtt,'(a)') trim(adjustl(sttr(2)))
where string 'sttr (2)is '(A72,1X,A,1X,I6.6) ' ` , which I confirm by printing fmtt like
WRITE(*,'(a)')fmtt
When I use string fmtt as format in a write statement like
WRITE (12, fmtt) ALINE,SFFIX(1:NUM),LINENO
I get error message
forrtl : info(58) format syntax error at or near '(A72,1X,A,1X,I6.6) '
Though I am not an expert I expected it to work as format is supposed to be a character string. Where am I wrong? I wanted to do this to make format dependent on user input. Thanking you.
Probably the single quotation marks ' ' are making problem. Following code is working fine.
implicit none
character(len=30) :: fmtt
fmtt = '(A72,1X,A,1X,I6.6)'
write(*,fmtt)"first_character","second_character",230
stop
end
Note that print*,fmtt give the output without single quotes. I follow the method given in http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/format.html . Hopefully this will help you.
I'm doing the Stanford xcode class CS193P assignment #2 and I'm getting some errors. The tasks is to write a calculator program with variables. I am using Xcode 3.2.6 www.stanford.edu/class/.../Assignment%202_1.pdf
I'm getting the error Expected expression before '#' token when I am declaring vp
#define VARIABLE_PREFIX #“%”
- (void)setVariableAsOperand:(NSString *)variableName
{
NSString *vp = VARIABLE_PREFIX; (error is on this line)
NSString *variable = [vp stringByAppendingString:variableName];
[self addObjectToExpression:variable];
}
Does anyone know how to fix this problem? Message me if you have any questions. Thanks for your help!
Quotes in C++ have to be of the right kind, i.e. " (U+0022, QUOTATION MARK). Some applications (read: not proper text editors) will convert typed quotes into ‘fancy’ ones, e.g. “ (U+201C, LEFT DOUBLE QUOTATION MARK) and ” (U+201D, RIGHT DOUBLE QUOTATION MARK).
Watch out for copying code via a word processor, e-mail composer, etc. And if you need to examine a character your text editor of choice might be able to do it (I know Emacs can), or you can use tools like this one.