Preliminary regeneration support
[hcoop/domtool2.git] / src / acl.sml
index e57f186..be30fdf 100644 (file)
@@ -44,6 +44,8 @@ fun queryAll user =
                                      (class, SS.foldr (op::) [] values) :: out)
                                  [] classes
 
+fun users () = SM.foldri (fn (user, _, ls) => user :: ls) [] (!acl)
+
 fun whoHas {class, value} =
     SM.foldri (fn (user, classes, users) =>
                  case SM.find (classes, class) of
@@ -125,15 +127,21 @@ fun write fname =
                                      TextIO.output (outf, value)))
 
        val writeClasses = SM.appi (fn (class, values) =>
-                                      (TextIO.output (outf, class);
-                                       writeValues values;
-                                       TextIO.output (outf, "\n")))
+                                      if SS.isEmpty values then
+                                          ()
+                                      else
+                                          (TextIO.output (outf, class);
+                                           writeValues values;
+                                           TextIO.output (outf, "\n")))
 
        val writeUsers = SM.appi (fn (user, classes) =>
-                                    (TextIO.output (outf, user);
-                                     TextIO.output (outf, "\n");
-                                     writeClasses classes;
-                                     TextIO.output (outf, "\n")))
+                                    if SM.numItems classes = 0 then
+                                        ()
+                                    else
+                                        (TextIO.output (outf, user);
+                                         TextIO.output (outf, "\n");
+                                         writeClasses classes;
+                                         TextIO.output (outf, "\n")))
     in
        writeUsers (!acl);
        TextIO.closeOut outf