This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

2 things


Firstly, is it possible for libgcj to affect the compiler ? I just
installed a CVS version of libgcj, and now find I can't compile
because cc1 and jc1 both reply with:

jc1: Invalid option `-fno-use-divide-subroutine'

It's possible someone has installed a new version of egcs which is causing
the problem, but I don't think so (there's nothing on the internal update
list)


Also, here's a (very poor!) patch for Runtime.exec() which takes into 
account a single level of quoting in a passed-in execution string. So
you can call exec("find /tmp -name xxx -printf '%p %AH'") for example.

It really needs a lot more to make it robust - chack for escaped quotes, 
multiple level of quotes etc. Alternatively, just pass strings straight
through and create a single string from the array-type call. I did think
of doing this, but unfortunately I have a deadline to meet :-(



[simon@donerkebab lang]# diff Runtime.java /tmp/Runtime.java
39,45c39
<     boolean inQuotes = false;     // Whether we're aggregating tokens
<     String quotedText = "";       // Text within quotes
< 
<     // Use the string tokeniser to split based on whitespace, but ask
<     // for the tokens so we can process quoted text as a single entity
<     String delimiters = " \t\n\r'\"";
<     StringTokenizer st = new StringTokenizer(prog, delimiters, true);
---
>     StringTokenizer st = new StringTokenizer(prog);
47,50d40
< 
<     // Process each of the tokens from the tokeniser. Should probably
<     // be done using StringBuffers.
<     int count = 0;
52,97c42,43
<       {
<       String token = st.nextToken ();
< 
<       if (token.length() == 1 && delimiters.indexOf(token) >= 0)
<         {
<         if (token.equals("\"") || token.equals("'"))
<           {
<           inQuotes   = ! inQuotes;
<           if (!inQuotes)
<             {
<             a[count++] = quotedText;
<               quotedText = "";
<               }
<             }
<         else 
<           {
<           if (inQuotes)
<             {
<             quotedText += token;
<             }
<           }
<       }
<       else
<         {
<         if (!inQuotes)
<             {
<             a[count++] = token;
<           }
<         else
<           {
<           quotedText += token;
<           }
<         }
<       }
< 
<     // Copy the a[] array to a new array (b[] :-) which only contains
<     // 'count' entries rather than st.countTokens()
< 
<     String b[] = new String[count];
<     for (int i=0; i<count; i++)
<       {
<       b[i] = a[i];
<       }
< 
< 
<     return exec (b, envp);
---
>       a[i] = st.nextToken ();
>     return exec (a, envp);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]