static int backup(BW *bw) { if (!bw->b->backup && !nobackups && !bw->o.nobackup && bw->b->name && bw->b->name[0]) { char tmp[1024]; char name[1024]; #ifdef __MSDOS__ int x; if (backpath) { char *t = vsncpy(NULL,0,sz(backpath)); t = canonical(t); joe_snprintf_2(name, SIZEOF(name), "%s/%s", t, namepart(tmp, SIZEOF(tmp), bw->b->name)); vsrm(t); } else { joe_snprintf_1(name, SIZEOF(name), "%s", bw->b->name); } for (x = zlen(name); name[--x] != '.';) { if (name[x] == '\\' || (name[x] == ':' && x == 1) || x == 0) { x = zlen(name); break; } } zlcpy(name + x, SIZEOF(name) - x, ".bak"); #else /* Create backup file name */ const char *simple_backup_suffix = getenv("SIMPLE_BACKUP_SUFFIX"); if (simple_backup_suffix == NULL) { simple_backup_suffix = "~"; } if (backpath) { char *t = vsncpy(NULL, 0, sz(backpath)); t = canonical(t); joe_snprintf_3(name, SIZEOF(name), "%s/%s%s", t, namepart(tmp, SIZEOF(tmp), dequote(bw->b->name)), simple_backup_suffix); vsrm(t); } else { joe_snprintf_2(name, SIZEOF(name), "%s%s", dequote(bw->b->name), simple_backup_suffix); } /* Attempt to delete backup file first */ unlink(name); #endif /* Copy original file to backup file */ if (cp(dequote(bw->b->name), name)) { return 1; } else { bw->b->backup = 1; return 0; } } else { return 0; } }
struct high_color *find_color(struct high_color *colors, unsigned char *name, unsigned char *syn) { unsigned char bf[256]; struct high_color *color; joe_snprintf_2(bf, sizeof(bf), "%s.%s", syn, name); for (color = colors; color; color = color->next) { if (!zcmp(color->name, bf)) { break; } } if (color) { return color; } for (color = colors; color; color = color->next) { if (!zcmp(color->name, name)) { break; } } return color; }
void init_gettext(const char *s) { FILE *f; char buf[1024]; joe_snprintf_2(buf, SIZEOF(buf), "%slang/%s.po",JOEDATA,s); if ((f = fopen(buf, "r"))) { /* Try specific language, like en_GB */ gettext_ht = htmk(256); load_po(f); } else if (s[0] && s[1]) { /* Try generic language, like en */ joe_snprintf_3(buf, SIZEOF(buf), "%slang/%c%c.po",JOEDATA,s[0],s[1]); if ((f = fopen(buf, "r"))) { gettext_ht = htmk(256); load_po(f); } } }