summaryrefslogtreecommitdiff
path: root/sort.go
diff options
context:
space:
mode:
Diffstat (limited to 'sort.go')
-rw-r--r--sort.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/sort.go b/sort.go
new file mode 100644
index 0000000..5d591c2
--- /dev/null
+++ b/sort.go
@@ -0,0 +1,27 @@
+package main
+
+import (
+ "os"
+)
+
+func (pb *Files) makeNewSortfile(pf *File) error {
+ f, _ := os.OpenFile(pf.Filebase+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+
+ header(f, pf)
+ pf.syncLock(f)
+
+ if argv.Mutex {
+ // use the mutex lock from the modified protoc.pb.go file
+ pf.Bases.Lockname = "all.Lock"
+ }
+
+ pf.Base.iterTop(f)
+ pf.Base.iterNext(f)
+ pf.iterSelect(f)
+ pf.appendUnique(f) // Append() enforce no unique keys
+ pf.iterSortBy(f)
+ pf.iterAll(f)
+ pf.iterDelete(f)
+ pf.iterFind(f)
+ return nil
+}