d2a9a3012b99 — Sean Farley 12 years ago
fast-bookmark: change prototype to pass pwd only
1 files changed, 6 insertions(+), 6 deletions(-)

M fast-hg-bookmark.c
M fast-hg-bookmark.c +6 -6
@@ 28,12 28,12 @@ void go_up_one_dir(char* dir_path) {
 }
 
 /* return 0 if successfully printed out from file */
-int cat_file(const char *hg_path, const char *file_name) {
+int cat_file(const char *pwd, const char *file_name) {
   FILE *f;
   char full_path[PATH_MAX+1];
   char c = EOF;
 
-  sprintf(full_path, "%s/%s", hg_path, file_name);
+  sprintf(full_path, "%s/%s", pwd, file_name);
   f = fopen(full_path, "r");
 
   if (f && (c=fgetc(f)) && c != EOF && c != '\n') { /* this checks for an empty file; probably a

          
@@ 52,10 52,10 @@ int cat_file(const char *hg_path, const 
   return -1;
 }
 
-int parse_bookmarks(const char *hg_path) {
-  if (cat_file(hg_path, "bookmarks.current")) {
+int parse_bookmarks(const char *pwd) {
+  if (cat_file(pwd, ".hg/bookmarks.current")) {
     /* fallback to branch name if bookmark isn't active */
-    return cat_file(hg_path, "branch");
+    return cat_file(pwd, ".hg/branch");
   }
 
   return 0;

          
@@ 72,7 72,7 @@ int main() {
     sprintf(hg_path, "%s/.hg", pwd);
     denied = access(hg_path, R_OK);
 
-    if (!denied) return parse_bookmarks(hg_path);
+    if (!denied) return parse_bookmarks(pwd);
 
     go_up_one_dir(pwd);
   }