home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,695 of 243,242   
   Michael S to Michael S   
   Re: srand(0)   
   02 Jan 26 16:18:39   
   
   From: already5chosen@yahoo.com   
      
   On Fri, 2 Jan 2026 14:32:07 +0200   
   Michael S  wrote:   
   >   
   >   
   > More interesting and meaningful question is how to do the reverse.   
   > I.e. how to convert an argv[] array into flat form in a way that   
   > guarantees that CommandLineToArgvW() parses it back into original   
   > form? Is it even possible in general case or there exist limitations   
   > (ignoring, for sake of brevity, 2*15-1 size limit)?   
   >   
   > Microsoft certainly has reverse conversion implemented, e.g. here:   
   > https://learn.microsoft.com/en-us/cpp/c-runtime-library/refere   
   ce/spawnv-wspawnv   
   >   
      
   Experimenting with _spawnv() shows that Microsoft made no effort in the   
   direction of invertible serialization/de-serialization of argv[] lists.   
   That is, as long as there are no double quotes, everything works as   
   expected. But when there are double quotes in the original argv[] then   
   more often than not they can't be passed exactly.   
      
   An exact result of de-serialization in presence of unusually placed   
   " characters depends on the version of the library.   
   Very old versions, like those before UCRT or relatively new   
   versions of UCRT, like one in VS2022, do not produce an exact   
   inversion, but otherwise their results are reasonable. The version of   
   the library supplied with UCRT variant of msys2 tools is much less   
   reasonable. I'd rather characterize it as buggy.   
   Frankly, I don't understand how it is possible. It leads me to believe   
   that parsing routines in C RTL do not use system-provided parser and   
   instead do parsing by themselves.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca