+
+void strip_casl2_comment(char *s)
+{
+ bool quoting = false;
+
+ for(int i = 0; s[i]; i++) {
+ /* 「'」で囲まれた文字列の場合。「''」は無視 */
+ if(s[i] == '\'' && s[i+1] != '\'' && (quoting == false || s[i-1] != '\'')) {
+ quoting = !quoting;
+ /* 「'」で囲まれた文字列でない場合、文字列末尾の「;」以降を削除 */
+ } else if(quoting == false && s[i] == ';') {
+ s[i] = '\0';
+ break;
+ }
+ }
+}
+
+char *strrev(const char *s)
+{
+ char *t = strdup_chk(s, "strrev.t");
+ int l = strlen(t);
+
+ for(int i = 0; i < l-1-i; i++) {
+ char tmp = t[i];
+ t[i] = t[l-1-i];
+ t[l-1-i] = tmp;
+ }
+ return t;
+}