1 // -*- compile-command: "g++ win2unix.cc -o win2unix" -*- 2 #include <string> 3 #include <iostream> 4 #include <fstream> 5 #include <unistd.h> 6 #include <string.h> 7 8 using namespace std; 9 10 11 // Convert absolute installer Windows path to a Cygwin path 12 // and write corresponding files runxcas.fr/es/en main(int argc,char ** argv)13int main(int argc,char ** argv){ 14 if (argc<2) 15 return 1; 16 string s(argv[1]); 17 for (int i=2;i<argc;++i){ 18 s += ' '; 19 s += argv[i]; 20 } 21 // if (!s.empty() && s[s.size()-1]!='\\') s += '\\'; 22 const char * ptr=s.c_str(); 23 int l=strlen(ptr); 24 if (l<2) 25 return 2; 26 /* 27 string s_nospace; 28 for (int i=0;i<l;++i){ 29 if (s[i]==' ') 30 s_nospace+="\\ "; 31 else 32 s_nospace+=s[i]; 33 } 34 */ 35 string unixpath("/cygdrive/"); 36 unixpath += *ptr; 37 ++ptr; 38 for (++ptr;*ptr;++ptr){ 39 switch (*ptr){ 40 case '\\': 41 unixpath += '/'; 42 break; 43 default: 44 unixpath += *ptr; 45 } 46 } 47 chdir(unixpath.c_str()); 48 ofstream bf("cxcasfr.bat"); 49 // Was bf << "set PATH=%PATH%;" << s << endl; 50 bf << "set PATH=" << s << ";%PATH%" << endl; 51 bf << "bash.exe '" << unixpath << "/runxcas.fr' %1" << endl; 52 ofstream cbf("xcasfr.bat"); 53 // Was bf << "set PATH=%PATH%;" << s << endl; 54 cbf << "set PATH=" << s << ";%PATH%" << endl; 55 cbf << "bash.exe '" << unixpath << "/runxcas.fr' %1" << endl; 56 ofstream of("runxcas.fr"); 57 of << "#! /bin/bash\nexport LANG=fr_FR.UTF-8\n"; 58 of << "export XCAS_ROOT='" << unixpath << "'\n"; 59 of << "# export XCAS_HOME='/cygdrive/p'\n"; 60 of << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 61 of << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 62 of << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 63 of.close(); 64 ofstream ebf("cxcases.bat"); 65 ebf << "set PATH=" << s << ";%PATH%" << endl; 66 ebf << "bash.exe '" << unixpath << "/runxcas.es' %1" << endl; 67 ofstream bf1("xcases.bat"); 68 bf1 << "set PATH=" << s << ";%PATH%" << endl; 69 bf1 << "bash.exe '" << unixpath << "/runxcas.es' %1" << endl; 70 ofstream of1("runxcas.es"); 71 of1 << "#! /bin/bash\nexport LANG=es_ES.UTF-8\n"; 72 of1 << "export XCAS_ROOT='" << unixpath << "'\n"; 73 of1 << "# export XCAS_HOME='/cygdrive/p'\n"; 74 of1 << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 75 of1 << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 76 of1 << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 77 of1.close(); 78 ofstream grf1("xcasgre.bat"); 79 grf1 << "set PATH=" << s << ";%PATH%" << endl; 80 grf1 << "bash.exe '" << unixpath << "/runxcas.gre' %1" << endl; 81 grf1.close(); 82 ofstream grf2("runxcas.gre"); 83 grf2 << "#! /bin/bash\nexport LANG=el_GR.UTF-8\n"; 84 grf2 << "export XCAS_ROOT='" << unixpath << "'\n"; 85 grf2 << "# export XCAS_HOME='/cygdrive/p'\n"; 86 grf2 << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 87 grf2 << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 88 grf2 << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 89 grf2.close(); 90 ofstream enbf("cxcasen.bat"); 91 enbf << "set PATH=" << s << ";%PATH%" << endl; 92 enbf << "bash.exe '" << unixpath << "/runxcas.en' %1" << endl; 93 ofstream bf2("xcasen.bat"); 94 bf2 << "set PATH=" << s << ";%PATH%" << endl; 95 bf2 << "bash.exe '" << unixpath << "/runxcas.en' %1" << endl; 96 ofstream of2("runxcas.en"); 97 of2 << "#! /bin/bash\nexport LANG=en\n"; 98 of2 << "export XCAS_ROOT='" << unixpath << "'\n"; 99 of2 << "# export XCAS_HOME='/cygdrive/p'\n"; 100 of2 << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 101 of2 << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 102 of2 << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 103 of2.close(); 104 ofstream bf3("xcaszh.bat"); 105 bf3 << "set PATH=" << s << ";%PATH%" << endl; 106 bf3 << "bash.exe '" << unixpath << "/runxcas.zh' %1" << endl; 107 ofstream of3("runxcas.zh"); 108 of3 << "#! /bin/bash\nexport LANG=zh\n"; 109 of3 << "export XCAS_ROOT='" << unixpath << "'\n"; 110 of3 << "# export XCAS_HOME='/cygdrive/p'\n"; 111 of3 << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 112 of3 << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 113 of3 << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 114 of3.close(); 115 ofstream bf4("xcasde.bat"); 116 bf4 << "set PATH=" << s << ";%PATH%" << endl; 117 bf4 << "bash.exe '" << unixpath << "/runxcas.de' %1" << endl; 118 ofstream of4("runxcas.de"); 119 of4 << "#! /bin/bash\nexport LANG=de\n"; 120 of4 << "export XCAS_ROOT='" << unixpath << "'\n"; 121 of4 << "# export XCAS_HOME='/cygdrive/p'\n"; 122 of4 << "# export XCAS_AUTOSAVEFOLDER='/cygdrive/p'\n"; 123 of4 << "export XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 124 of4 << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\" \"$1\"\n"; 125 of4.close(); 126 return 0; 127 } 128 129 /* 130 ofstream bf0("altair.bat"); 131 bf0 << "set PATH=" << s << ";%PATH%" << endl; 132 bf0 << "bash.exe '" << unixpath << "/runxcas.alt'" << endl; 133 ofstream of0("runxcas.alt"); 134 of << "#! /bin/bash\nexport LANG=fr_FR:fr\n"; 135 of << "export XCAS_ROOT='" << unixpath << "'"; 136 of << "\nexport XCAS_LOCALE=\"$XCAS_ROOT/locale/\"\n"; 137 of << "export XCAS_HELP=\"$XCAS_ROOT/aide_cas\"\n\"$XCAS_ROOT/xcas.exe\"\n"; 138 of.close(); 139 */ 140