rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on May 19, 2009, 04:22:35 PM

Title: modification of function dequote()
Post by: Mars on May 19, 2009, 04:22:35 PM
There is a conflict in the procedure exec_ during the call to dequote, it is not the one of utilib.pas which is executed but that of main.pas with them MARKER_QUOTE.

I suggest you to rename the 'dequote' in main.pas by  'macrodequote' and move it at same place of 'macroquote'

you have to change all calls to 'dequote'  in procedure 'cbmacros'  by the 'macrodequote' excepted in the procedure exec_()

After that, there will not be possible confusion anymore

I take advantage of it to add a boolean function

function isAnyMacroIn(s:string):boolean; inline;
begin result:=pos(MARKER_OPEN, s) > 0 end;

function noMacrosAllowed(s:string):string; inline;
begin result:=if_(not isAnyMacroIn(s), s) end; // prevent hack attempts

function macroQuoted(s:string):boolean;    // add by mars
  result:=ansiStartsStr(MARKER_QUOTE, s) and ansiEndsStr(MARKER_UNQUOTE, s);

function macroQuote(s:string):string;
  t: string;
if not anyMacroMarkerIn(s) then
// an UNQUOTE would invalidate our quoting, so let's encode any of it
replace(t, '&#'+intToStr(charToUnicode(t[1]))+';', 1,1);
end; // macroQuote

function macrodequote(s:string):string;  //moved from dequote
if ansiStartsStr(MARKER_QUOTE, s) and ansiEndsStr(MARKER_UNQUOTE, s) then
  result:=copy(s, length(MARKER_QUOTE)+1, length(s)-length(MARKER_QUOTE)-length(MARKER_UNQUOTE) );
end; // macrodequote

function loadDescriptionFile(fn:string):string;
if result = '' then
if (result > '') and mainfrm.oemForIonChk.checked then
  OEMToCharBuff(@result[1], @result[1], length(result));
end; // loadDescription

Le premier qui me demande à quoi cela va servir, il n'a qu'à attendre la sortie de la build 240, c'est en rapport avec la macro 'no pipe'. Rejetto, j'espère que tu te montreras assez curieux pour me contacter: le problème du | est résolu et fonctionnel  (  :D

j'allais oublier une dernière modification à main.pas.
    if name = 'add to log' then
      try mainfrm.add2log(macrodequote(p),, stringToColor(par(1,'color')) );
      except mainfrm.add2log(macrodequote(p), end;

then  {.add to log|{:{.one macro.}:}.}   add      '{.one macro.}'   to the log  and not '{:{.one macro.}:}' or the reuslt of '{.one macro.}'  if you ommit the macroquote.

The second solution, the simplest but remaining ambigue
  procedure exec_();
    s: string;
  s:=utilLib.dequote(par(1));     //marsmars
  if fileOrDirExists(s) then
    s:=quoteIfAnyChar(' ', s);
    setVar(parEx('out'), captureExec(utilLib.dequote(p)+' '+s));      //marsmars
  except spaceIf(exec(utilLib.dequote(p), s)) end;      //marsmars
  end; // exec_
Title: Re: modification of function dequote()
Post by: rejetto on May 21, 2009, 10:19:37 PM
i accept and apply the suggestion about dequote(),
but exec_() was actually meant to call macroDequote, and not utilLib.dequote()
it was a trick to let you use the pipe, because it is useful at command line. ;)

why you need to macrodequote on addToLog ?
who needs to log macros? :)

i'm interested in your suggestion to solve the pipe problem. sadly i have very little time these days :(.
write me an email if you like.

i have an idea that i don't know if it will be a problem: to automatically macroDequote all parameters.
i didn't test yet. maybe it's a crap with very bad side-effects, like my previous idea for \p :D. i don't know yet.
Title: Re: modification of function dequote()
Post by: Mars on May 21, 2009, 10:28:25 PM
tu veux vraiment te faire tirer les oreilles
If you want to add the expression of a macro in 'add to log' without this is estimated, you are obliged to frame it between two marker_quote but these appear in the log, regrettably.

To add dequote() in 'add to log' allows to choose between the result or the expression of the macro

all the question is here! ;)

tu devrais t'intéresser en priorité à ce post

is not \p used as page jump, as \f to form feed?
Title: Re: modification of function dequote()
Post by: rejetto on May 21, 2009, 11:46:44 PM
i wonder if i can do something like this

    for i:=0 to pars.count-1 do
      pars[ i]:=macroDequote(pars[ i]);

it may be a nice or terrible thing, i don't know :D