]> SALOME platform Git repositories - tools/install.git/commitdiff
Salome HOME
Fix pb on some platform with awk: limited sprintf() function buffer size
authorvsr <vsr@opencascade.com>
Fri, 29 Sep 2006 13:42:20 +0000 (13:42 +0000)
committervsr <vsr@opencascade.com>
Fri, 29 Sep 2006 13:42:20 +0000 (13:42 +0000)
config_files/common.sh

index 2f33ae8ed98297846ad5f3ca6fd2aba909689d59..b4b5bb8f2077a72a775343d914e15570ae82daed 100755 (executable)
@@ -155,33 +155,45 @@ cat >> ${install_work}/_$SHRC <<EOF
 # the third parameter defines the mode: 0 - append, 1 - prepend
 cleandup() {
 out_var=\`echo \$1 \$2 | awk -v dir=\$3 '{                   \\
-    na = split(\$2,a,":");                                \\
-    if ( \$1 == "<empty>") nb = split("",b,":");          \\
-    else nb = split(\$1,b,":");                           \\
-    s = "" ;                                             \\
-    for(i=1;i<=nb;i++) {                                 \\
-       if(!(b[i] in ccc)) {                             \\
-           if(length(s)!=0)                             \\
-               s = sprintf("%s:",s);                    \\
-           s = sprintf("%s%s",s,b[i]);                  \\
-           ccc[b[i]];                                   \\
-       };                                               \\
-    };                                                   \\
-    s1 = "";                                             \\
-    for(i=1;i<=na;i++) {                                 \\
-       if(!(a[i] in ccc)) {                             \\
-           if(length(s1)!=0)                            \\
-               s1 = sprintf("%s:",s1);                  \\
-           s1 = sprintf("%s%s",s1,a[i]);                \\
-           ccc[a[i]];                                   \\
-       };                                               \\
-    };                                                   \\
-    if(dir)                                              \\
-       s = length(s) == 0 ? s1 : sprintf("%s:%s",s1,s); \\
-    else                                                 \\
-       s = length(s1) == 0 ? s : sprintf("%s:%s",s,s1); \\
-    printf("%s\n",s);                                    \\
-    }'\`
+     na = split(\$2,a,":");                               \\
+     k1=0;                                               \\
+     bbb[k1++]="";                                       \\
+     ccc[""];                                            \\
+     if(\$1 != "<empty>") {                               \\
+       nb = split(\$1,b,":");                             \\
+       for(i=1;i<=nb;i++) {                              \\
+         if(!(b[i] in ccc) ) {                           \\
+          ccc[b[i]];                                    \\
+           bbb[k1++]=b[i];                               \\
+        };                                              \\
+       };                                                \\
+     };                                                  \\
+     k2=0;                                               \\
+     aaa[k2++]="";                                       \\
+     for(i=1;i<=na;i++) {                                \\
+       if(!(a[i] in ccc)) {                              \\
+         ccc[a[i]];                                      \\
+         aaa[k2++]=a[i];                                 \\
+       };                                                \\
+     };                                                  \\
+     ORS=":";                                            \\
+     if(dir) {                                           \\
+       for(i=1;i<k2;i++) {                               \\
+         print aaa[i];                                   \\
+       }                                                 \\
+       for(i=1;i<k1;i++) {                               \\
+         print bbb[i];                                   \\
+       }                                                 \\
+     }                                                   \\
+     else {                                              \\
+       for(i=1;i<k1;i++) {                               \\
+         print bbb[i];                                   \\
+       }                                                 \\
+       for(i=1;i<k2;i++) {                               \\
+         print aaa[i];                                   \\
+       }                                                 \\
+     }                                                   \\
+   }' | sed -e 's/\(.*\):/\1/g'\`
 echo \$out_var
 }
 ### exporta ###
@@ -228,31 +240,44 @@ cat >> ${install_work}/_$CSHRC <<EOF
 # the third parameter defines the mode: 0 - append, 1 - prepend
 alias cleandup "echo \!:1 \!:2 | awk -v dir=\!:3         \\\\
 '"'{ na = split(\$2,a,":");                               \\\\
-     nb = split(\$1,b,":");                               \\\\
-     s = "" ;                                            \\\\
-     for(i=1;i<=nb;i++) {                                \\\\
-       if(!(b[i] in ccc)) {                             \\\\
-           if(length(s)!=0)                             \\\\
-               s = sprintf("%s:",s);                    \\\\
-           s = sprintf("%s%s",s,b[i]);                  \\\\
-           ccc[b[i]];                                   \\\\
-       };                                               \\\\
-    };                                                   \\\\
-    s1 = "";                                             \\\\
-    for(i=1;i<=na;i++) {                                 \\\\
-       if(!(a[i] in ccc)) {                             \\\\
-           if(length(s1)!=0)                            \\\\
-               s1 = sprintf("%s:",s1);                  \\\\
-           s1 = sprintf("%s%s",s1,a[i]);                \\\\
-           ccc[a[i]];                                   \\\\
-       };                                               \\\\
-    };                                                   \\\\
-    if(dir)                                              \\\\
-       s = length(s) == 0 ? s1 : sprintf("%s:%s",s1,s); \\\\
-    else                                                 \\\\
-       s = length(s1) == 0 ? s : sprintf("%s:%s",s,s1); \\\\
-    printf("%s\n",s);                                    \\\\
-    }'"'"
+     k1=0;                                               \\\\
+     bbb[k1++]="";                                       \\\\
+     ccc[""];                                            \\\\
+     if(\$1 != "<empty>") {                               \\\\
+       nb = split(\$1,b,":");                             \\\\
+       for(i=1;i<=nb;i++) {                              \\\\
+         if(!(b[i] in ccc) ) {                           \\\\
+          ccc[b[i]];                                    \\\\
+           bbb[k1++]=b[i];                               \\\\
+        };                                              \\\\
+       };                                                \\\\
+     };                                                  \\\\
+     k2=0;                                               \\\\
+     aaa[k2++]="";                                       \\\\
+     for(i=1;i<=na;i++) {                                \\\\
+       if(!(a[i] in ccc)) {                              \\\\
+         ccc[a[i]];                                      \\\\
+         aaa[k2++]=a[i];                                 \\\\
+       };                                                \\\\
+     };                                                  \\\\
+     ORS=":";                                            \\\\
+     if(dir) {                                           \\\\
+       for(i=1;i<k2;i++) {                               \\\\
+         print aaa[i];                                   \\\\
+       }                                                 \\\\
+       for(i=1;i<k1;i++) {                               \\\\
+         print bbb[i];                                   \\\\
+       }                                                 \\\\
+     }                                                   \\\\
+     else {                                              \\\\
+       for(i=1;i<k1;i++) {                               \\\\
+         print bbb[i];                                   \\\\
+       }                                                 \\\\
+       for(i=1;i<k2;i++) {                               \\\\
+         print aaa[i];                                   \\\\
+       }                                                 \\\\
+     }                                                   \\\\
+  }'"' | sed -e 's/\(.*\):/\1/g'"
 ### setenva ###
 # appends directory or set of directories, separated by ':' (second parameter)
 # to the variable (first parameter)