s4-scripting: fix wrong indent that caused gen_ntstatus.py to fail.
authorGünther Deschner <gd@samba.org>
Wed, 30 Sep 2015 06:14:06 +0000 (08:14 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 30 Sep 2015 21:51:12 +0000 (23:51 +0200)
Verified it now works again with:

./source4/scripting/bin/gen_ntstatus.py libcli/util/ntstatus.h MS-ERREF-2.3.1.NTSTATUS libcli/util/nterr.c

MS-ERREF-2.3.1.NTSTATUS as the copied content from
https://msdn.microsoft.com/en-us/library/cc704588.aspx.

Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/scripting/bin/gen_ntstatus.py

index 3625ad72cac13edb383b856e19c461bfbcb735c9..bf57fefc228d080721cd5631ab1a07229630fc2b 100755 (executable)
@@ -62,6 +62,8 @@ def transformErrorName( error_name ):
 def parseErrorDescriptions( file_contents, isWinError ):
     count = 0
     for line in file_contents:
+        if line == None or line == '\t' or line == "" or line == '\n':
+            continue
         content = line.strip().split(None,1)
         # start new error definition ?
         if line.startswith("0x"):
@@ -78,17 +80,17 @@ def parseErrorDescriptions( file_contents, isWinError ):
                 print "Error parsing file as line %d"%count
                 sys.exit()
             err = Errors[-1]
-            if err.err_define == None:    
+            if err.err_define == None:
                 err.err_define = transformErrorName(content[0])
-        else:
-            if len(content) > 0:
-                desc =  escapeString(line.strip())
-                if len(desc):
-                    if err.err_string == "":
-                        err.err_string = desc
-                    else:
-                        err.err_string = err.err_string + " " + desc
-        count = count + 1
+            else:
+                if len(content) > 0:
+                    desc =  escapeString(line.strip())
+                    if len(desc):
+                        if err.err_string == "":
+                            err.err_string = desc
+                        else:
+                            err.err_string = err.err_string + " " + desc
+            count = count + 1
     print "parsed %d lines generated %d error definitions"%(count,len(Errors))
 
 def parseErrCodeString(error_code_string):
@@ -147,21 +149,21 @@ def generateSourceFile(out_file):
     out_file.write(" * [MS-ERREF] http://msdn.microsoft.com/en-us/library/cc704588.aspx\n")
     out_file.write(" */\n")
     for err in ErrorsToCreatDescFor:
-       out_file.write("        { N_(\"%s\"), %s },\n"%(err.err_string, err.err_define))
+        out_file.write("       { N_(\"%s\"), %s },\n"%(err.err_string, err.err_define))
     out_file.write("\n\n")
     out_file.write("/*\n")
     out_file.write(" * New descriptions for new errors generated from\n")
     out_file.write(" * [MS-ERREF] http://msdn.microsoft.com/en-us/library/cc704588.aspx\n")
     out_file.write(" */\n")
     for err in ErrorsToUse:
-       out_file.write("        { N_(\"%s\"), %s },\n"%(err.err_string, err.err_define))
+        out_file.write("       { N_(\"%s\"), %s },\n"%(err.err_string, err.err_define))
     out_file.write("\n\n");
     out_file.write("/*\n")
     out_file.write(" * New descriptions for new errors generated from\n")
     out_file.write(" * [MS-ERREF] http://msdn.microsoft.com/en-us/library/cc704588.aspx\n")
     out_file.write(" */\n")
     for err in ErrorsToUse:
-       out_file.write("        { \"%s\", %s },\n"%(err.err_define, err.err_define))
+        out_file.write("       { \"%s\", %s },\n"%(err.err_define, err.err_define))
 
 def def_in_list(define, err_def_with_desc):
     for item in err_def_with_desc:
@@ -231,9 +233,11 @@ def main ():
     file_contents = open(input_file3,"r")
     has_already_desc = file_contents.readlines()
     processErrorDescription(has_already_desc)
+    print "writing new headerfile: %s"%headerfile_name
     out_file = open(headerfile_name,"w")
     generateHeaderFile(out_file)
     out_file.close()
+    print "writing new headerfile: %s"%sourcefile_name
     out_file = open(sourcefile_name,"w")
     generateSourceFile(out_file)
     out_file.close()