trans-coord-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trans-coord/gnun/server/gnun recode-unescape.in [sr-hr]


From: Kaloian Doganov
Subject: trans-coord/gnun/server/gnun recode-unescape.in [sr-hr]
Date: Sun, 02 Aug 2009 13:31:15 +0000

CVSROOT:        /sources/trans-coord
Module name:    trans-coord
Branch:         sr-hr
Changes by:     Kaloian Doganov <kaloian>       09/08/02 13:31:15

Added files:
        gnun/server/gnun: recode-unescape.in 

Log message:
        New file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/trans-coord/gnun/server/gnun/recode-unescape.in?cvsroot=trans-coord&only_with_tag=sr-hr&rev=1.1.2.1

Patches:
Index: recode-unescape.in
===================================================================
RCS file: recode-unescape.in
diff -N recode-unescape.in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ recode-unescape.in  2 Aug 2009 13:31:15 -0000       1.1.2.1
@@ -0,0 +1,89 @@
address@hidden@ \                                       -*-scheme-*-
+-e main --debug -s
+!#
+;; @configure_input@
+
+;; Copyright (C) 2009 Free Software Foundation, Inc.
+
+;; This file is part of GNUnited Nations.
+
+;; GNUnited Nations is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; GNUnited Nations is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNUnited Nations.  If not, see
+;; <http://www.gnu.org/licenses/>.
+
+(define version-message
+  (string-append
+   "recode-unescape (@PACKAGE_NAME@) @address@hidden"
+   "Copyright (C) 2009 Free Software Foundation, Inc.\n"
+   "You may redistribute copies of GNUnited Nations\n"
+   "under the terms of the GNU General Public License.\n"
+   "For more information about these matters, see the file named COPYING.\n"))
+
+; FIXME: Use AC_INIT's 5th argument and AC_PACKAGE_URL once Autoconf
+; 2.64 is released.
+(define help-message
+  (string-append
+   "Usage: recode-unescape [OPTION]\n"
+   "\n"
+   "      --version              Just print version info and return\n"
+   "      --help                 Print this usage information message\n"
+   "\n"
+   "Report bugs to @address@hidden"
+   "@PACKAGE_NAME@ home page: <http://www.gnu.org/software/@PACKAGE@/>\n"
+   "General help using GNU software: <http://www.gnu.org/gethelp/>\n"))
+
+(define option-grammar
+  '((version (value #f))
+    (help (value #f))))
+
+(use-modules (ice-9 regex)
+            (ice-9 rdelim)
+            (ice-9 getopt-long)
+            (srfi srfi-13))
+
+(define (main args)
+  (let* ((options (catch 'misc-error
+                        (lambda () (getopt-long args option-grammar))
+                        (lambda (key subr message args data)
+                          (die (apply format #f message args)))))
+        (opt (lambda args (apply option-ref options args))))
+    (cond ((opt 'version #f) (version))
+         ((opt 'help #f) (help))
+         (else
+          (display
+           (recode-unescape (recode-unescape (read-delimited ""))))))))
+
+(define (die message)
+  (display "recode-unescape: " (current-error-port))
+  (display message (current-error-port))
+  (newline (current-error-port))
+  (exit 2))
+
+(define (version)
+  (display version-message))
+
+(define (help)
+  (display help-message))
+
+; Converts all escapes to ordinary characters in STR.
+(define (recode-unescape str)
+  (with-output-to-string
+    (lambda ()
+      (regexp-substitute/global
+       (current-output-port)
+       "\\\\([0-9]+)"
+       str
+       'pre
+       (lambda (m)
+        (string (integer->char (string->number (match:substring m 1)))))
+       'post))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]