(
(* This file is read into mathraw to make the dump by makefile.skel.
   Sysinit.m is read automatically from Common/StartUp, before this file.
   The parentheses avoid leaving junk in In, Out, InString, and MessageList.
   (InString and MessageList added by bks 20 Feb 91.)
 *)

	Off[ General::intinit];
	System`Private`FatStuff;	
	(IntMessages[ x_String] := ToExpression[ "Messages[" <> x <> "]"]);
	(ClearRead[ symb_Symbol] :=
               	If[ MemberQ[ Attributes[ symb], ReadProtected],
                       	ClearAttributes[ symb, ReadProtected]]);
	(GetMessage[ part_] :=
       		Module[{Tag, msg},
               		{Tag, msg} = List @@ part ;
               		Tag = StringDrop[ ToString[ Tag], StringLength["Literal["]] ;
               		Tag = StringDrop[ Tag, -1] ;
               		msg = StringReplace[ msg, {"\"" -> "\\\"", "\n" -> "\\n"}] ;
               		{Tag, msg}
       		]);
	(MessageDump[file1_String, file2_String] :=
	        Module[{symbols, internal, result, msg = {}, usg = {}},
               		OpenWrite[ file1] ;
               		OpenWrite[ file2] ;
               		symbols = Map[ ToExpression, Names["System`*"]] ;
               		Map[ ClearRead, symbols] ;
               		internal = Map[ IntMessages, Names["System`*"]] ;
               		result =  Map[ GetMessage, Flatten[ internal]] ;
               		Map[ If[ StringPosition[ #[[1]], "usage"] === {},
                       		AppendTo[ msg, #],
                       		AppendTo[ usg, #]]&, result] ;
               		Map[ WriteString[file1,
                       		#[[1]] <> " = \"",#[[2]],"\"\n"]&, msg] ;
               		Map[ WriteString[file2,
                       		#[[1]] <> " = \"",#[[2]],"\"\n"]&, usg] ;
               		Close[ file1]
               		Close[ file2]
        	]);
	Off[ $$Media::obsym];
)
