summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-01-09 15:22:42 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-01-09 15:22:42 +0000
commit90a1e35737c0c02455d5fa85be7bd96339c9dc88 (patch)
treec42b6e522aff051481820912255572c10f205b6c
parentb5905a0ab6ffbcfe0e61f17bed255ea0cd59efbc (diff)
downloadperl-MDK-Common-90a1e35737c0c02455d5fa85be7bd96339c9dc88.tar
perl-MDK-Common-90a1e35737c0c02455d5fa85be7bd96339c9dc88.tar.gz
perl-MDK-Common-90a1e35737c0c02455d5fa85be7bd96339c9dc88.tar.bz2
perl-MDK-Common-90a1e35737c0c02455d5fa85be7bd96339c9dc88.tar.xz
perl-MDK-Common-90a1e35737c0c02455d5fa85be7bd96339c9dc88.zip
perl_checker: entries in generated pot file are sorted by files
-rw-r--r--perl-MDK-Common.spec5
-rw-r--r--perl_checker.src/info.ml6
-rw-r--r--perl_checker.src/info.mli1
-rw-r--r--perl_checker.src/parser_helper.ml26
-rw-r--r--perl_checker.src/parser_helper.mli3
5 files changed, 25 insertions, 16 deletions
diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec
index 3fdb016..279c04d 100644
--- a/perl-MDK-Common.spec
+++ b/perl-MDK-Common.spec
@@ -2,7 +2,7 @@
# do not change the version here, change in MDK/Common.pm.pl
%define version THEVERSION
-%define release 1mdk
+%define release 2mdk
%ifarch x86_64
%define build_option PERL_CHECKER_TARGET='debug-code BCSUFFIX=""'
@@ -72,6 +72,9 @@ rm -rf $RPM_BUILD_ROOT
# MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common
%changelog
+* Fri Jan 9 2004 Pixel <pixel@mandrakesoft.com> 1.1.10-2mdk
+- perl_checker: entries in generated pot file are sorted by files
+
* Wed Jan 7 2004 Pixel <pixel@mandrakesoft.com> 1.1.10-1mdk
- add whereis_binary()
diff --git a/perl_checker.src/info.ml b/perl_checker.src/info.ml
index ca14f9e..d5a1ce8 100644
--- a/perl_checker.src/info.ml
+++ b/perl_checker.src/info.ml
@@ -59,10 +59,14 @@ let pos2s (file, a, b) = sprintf "(%s, %d, %d)" file a b
let pos2sfull pos =
try
- let (file, line, n1,n2) = pos2line pos in
+ let file, line, n1, n2 = pos2line pos in
sprintf "File \"%s\", line %d, character %d-%d\n" (absolute_file_to_file file) (line + 1) n1 n2
with Not_found -> failwith ("bad position " ^ pos2s pos)
+let pos2s_for_po pos =
+ let file, line, _, _ = pos2line pos in
+ absolute_file_to_file file ^ ":" ^ string_of_int (line + 1)
+
let is_on_same_line file (a,b) =
let line_a, _ = raw_pos2raw_line file a in
let line_b, _ = raw_pos2raw_line file b in
diff --git a/perl_checker.src/info.mli b/perl_checker.src/info.mli
index bd72bc7..d337316 100644
--- a/perl_checker.src/info.mli
+++ b/perl_checker.src/info.mli
@@ -11,6 +11,7 @@ val raw_pos2raw_line : string -> int -> int * int
val pos2line : string * int * int -> string * int * int * int
val pos2s : string * int * int -> string
val pos2sfull : string * int * int -> string
+val pos2s_for_po : string * int * int -> string
val is_on_same_line : string -> int * int -> bool
val is_on_same_line_current : int * int -> bool
val pos2sfull_current : int -> int -> string
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 557cf26..b95622e 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -687,7 +687,6 @@ let followed_by_comma expr true_comma =
let pot_strings = Hashtbl.create 16
-let pot_strings_and_file = Hashtbl.create 16
let po_comments = ref []
let po_comment esp = lpush po_comments esp.any
@@ -736,21 +735,25 @@ msgstr \"\"
| '\n' -> output_string fd "\\n\"\n\""
| c -> output_char fd c
in
- Hashtbl.iter (fun s po_comments ->
- match Hashtbl.find_all pot_strings_and_file s with
+ let sorted_pot_strings = List.sort (fun (_, pos_a) (_, pos_b) -> compare pos_a pos_b)
+ (Hashtbl.fold (fun k (v, _) l -> (k,v) :: l) pot_strings [] ) in
+ List.iter (fun (s, _) ->
+ match Hashtbl.find_all pot_strings s with
| [] -> ()
| l ->
- List.iter (fun po_comment -> output_string fd ("#. " ^ po_comment ^ "\n")) po_comments;
+ List.iter (fun _ -> Hashtbl.remove pot_strings s) l ;
- List.iter (fun _ -> Hashtbl.remove pot_strings_and_file s) l ;
- fprintf fd "#: %s\n" (String.concat " " (List.map (fun s -> Info.absolute_file_to_file s ^ ":1") l)) ;
+ List.iter (fun po_comment -> output_string fd ("#. " ^ po_comment ^ "\n")) (collect snd l);
+
+ let pos_l = List.sort compare (List.map fst l) in
+ fprintf fd "#: %s\n" (String.concat " " (List.map Info.pos2s_for_po pos_l)) ;
output_string fd "#, c-format\n" ;
output_string fd (if String.contains s '\n' then "msgid \"\"\n\"" else "msgid \"") ;
String.iter print_formatted_char s ;
output_string fd "\"\n" ;
output_string fd "msgstr \"\"\n\n"
- ) pot_strings ;
+ ) sorted_pot_strings ;
close_out fd
let call_raw force_non_builtin_func (e, para) =
@@ -769,13 +772,12 @@ let call_raw force_non_builtin_func (e, para) =
| "N" | "N_" ->
(match para with
- | [ List(String([ s, List [] ], (file, pos_a, _)) :: para) ] ->
+ | [ List(String([ s, List [] ], (_, pos_offset, _ as pos)) :: para) ] ->
if !Flags.generate_pot then (
- Hashtbl.replace pot_strings s ((try Hashtbl.find pot_strings s with Not_found -> []) @ !po_comments) ;
- po_comments := [] ;
- Hashtbl.add pot_strings_and_file s file ;
+ Hashtbl.add pot_strings s (pos, !po_comments) ;
+ po_comments := []
) ;
- let contexts = check_format_a_la_printf s pos_a in
+ let contexts = check_format_a_la_printf s pos_offset in
if f = "N" then
if List.length para < List.length contexts then
warn_rule "not enough parameters"
diff --git a/perl_checker.src/parser_helper.mli b/perl_checker.src/parser_helper.mli
index ede0d18..effa227 100644
--- a/perl_checker.src/parser_helper.mli
+++ b/perl_checker.src/parser_helper.mli
@@ -181,8 +181,7 @@ val to_Call_op_ :
Types.fromparser Types.prio_anyexpr Types.any_spaces_pos
val followed_by_comma :
Types.fromparser list -> bool -> Types.fromparser list
-val pot_strings : (string, string list) Hashtbl.t
-val pot_strings_and_file : (string, string) Hashtbl.t
+val pot_strings : (string, (string * int * int) * string list) Hashtbl.t
val po_comments : string list ref
val po_comment : string Types.any_spaces_pos -> unit
val check_format_a_la_printf : string -> int -> Types.maybe_context list