mldonkey-commits
[Top][All Lists]
Advanced

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

[Mldonkey-commits] mldonkey distrib/ChangeLog src/utils/lib/option...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/utils/lib/option...
Date: Sun, 07 Jul 2013 10:56:43 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       13/07/07 10:56:43

Modified files:
        distrib        : ChangeLog 
        src/utils/lib  : options.ml4 

Log message:
        patch #8105

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1569&r2=1.1570
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/lib/options.ml4?cvsroot=mldonkey&r1=1.32&r2=1.33

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1569
retrieving revision 1.1570
diff -u -b -r1.1569 -r1.1570
--- distrib/ChangeLog   7 Jul 2013 10:54:48 -0000       1.1569
+++ distrib/ChangeLog   7 Jul 2013 10:56:43 -0000       1.1570
@@ -15,6 +15,7 @@
 =========
 
 2013/07/07:
+8105: Config: report line and position for syntax errors in config files 
(ygrek)
 8104: BT: suppress warning for peers6 entry in tracker response (ygrek)
 7954: Fix handling of full disc (jcea)
 7917: Allow upnp_stub.c to be compiled on Mac OS X (zbroyar)

Index: src/utils/lib/options.ml4
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/lib/options.ml4,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- src/utils/lib/options.ml4   23 Oct 2010 18:22:29 -0000      1.32
+++ src/utils/lib/options.ml4   7 Jul 2013 10:56:43 -0000       1.33
@@ -252,6 +252,17 @@
          _ -> ())
     o.option_class.class_hooks  
   
+let count_lines ic pos =
+  seek_in ic 0;
+  let prev = ref 0 in
+  let lines = ref 0 in
+  while pos_in ic < pos do
+    prev := pos_in ic;
+    incr lines;
+    ignore (input_line ic);
+  done;
+  !lines, pos - !prev
+
 let really_load filename sections =
   let temp_file = filename ^ ".tmp" in
   if Sys.file_exists temp_file then
@@ -271,8 +282,9 @@
         try 
          parse_gwmlrc stream 
        with e ->
-          lprintf "Syntax error while parsing file %s at pos %d:(%s)\n"
-            filename (Stream.count s) (Printexc2.to_string e);
+          let (line,col) = count_lines ic (Stream.count s) in
+          lprintf "Syntax error while parsing file %s at position %d:%d: %s\n"
+            filename line col (Printexc2.to_string e);
           lprintf "it seems that %s is corrupt,\n" filename;
           lprintf "try to use a backup from %s\n"
             (Filename.concat (Sys.getcwd ()) "old_config");



reply via email to

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