Skip to content
Snippets Groups Projects
Commit e558fef4 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add an AStyle config that doesn't bother me.

Biggest issue with this one is it doesn't allow BSD-style continuation
indentation, and forces aligning with parens.
parent 08af4e40
No related branches found
No related tags found
No related merge requests found
Pipeline #7790 passed
--style=stroustrup
--indent=tab=8
--attach-extern-c
--attach-closing-while
--indent-switches
# Maybe...
#--indent-after-parens
--indent-continuation=1
--indent-preproc-block
--pad-oper
--pad-include
--pad-header
--unpad-paren
--unpad-brackets
--squeeze-lines=2
--squeeze-ws
--align-pointer=name
--align-reference=type
--min-conditional-indent=3
--break-closing-braces
--break-one-line-headers
# Danger!
--remove-braces
--break-return-type
--attach-return-type-decl
--convert-tabs
--max-code-length=115
...@@ -572,9 +572,8 @@ listcmp(const void *aptr, const void *bptr) ...@@ -572,9 +572,8 @@ listcmp(const void *aptr, const void *bptr)
item = abs(sortorder[i]); item = abs(sortorder[i]);
reverse = (sortorder[i] < 0 ? 1 : 0) ^ ((sort_order[item].flags & SORT_ORDER_REVERSED) ? 1 : 0); reverse = (sortorder[i] < 0 ? 1 : 0) ^ ((sort_order[item].flags & SORT_ORDER_REVERSED) ? 1 : 0);
if (sort_order[item].name) { if (sort_order[item].name) {
if (sort_order[item].flags & SORT_ORDER_STRING) { if (sort_order[item].flags & SORT_ORDER_STRING)
ret = stricmp(a + sort_order[item].offset, b + sort_order[item].offset); ret = stricmp(a + sort_order[item].offset, b + sort_order[item].offset);
}
else { else {
ret = ret =
intbufcmp(a + sort_order[item].offset, intbufcmp(a + sort_order[item].offset,
...@@ -587,10 +586,9 @@ listcmp(const void *aptr, const void *bptr) ...@@ -587,10 +586,9 @@ listcmp(const void *aptr, const void *bptr)
return ret; return ret;
} }
} }
else { else
return ret; return ret;
} }
}
return 0; return 0;
} }
...@@ -633,9 +631,8 @@ write_sortorder(void) ...@@ -633,9 +631,8 @@ write_sortorder(void)
inicontents = iniReadFile(inifile); inicontents = iniReadFile(inifile);
fclose(inifile); fclose(inifile);
} }
else { else
inicontents = strListInit(); inicontents = strListInit();
}
iniSetStringList(&inicontents, "SyncTERM", "SortOrder", ",", sortorders, &ini_style); iniSetStringList(&inicontents, "SyncTERM", "SortOrder", ",", sortorders, &ini_style);
if ((inifile = fopen(inipath, "w")) != NULL) { if ((inifile = fopen(inipath, "w")) != NULL) {
...@@ -675,10 +672,9 @@ edit_sorting(struct bbslist **list, int *listcount, int *ocur, int *obar, char * ...@@ -675,10 +672,9 @@ edit_sorting(struct bbslist **list, int *listcount, int *ocur, int *obar, char *
^ ((sort_order[abs(sortorder[i])].flags & SORT_ORDER_REVERSED) ? 1 : 0)) ^ ((sort_order[abs(sortorder[i])].flags & SORT_ORDER_REVERSED) ? 1 : 0))
strcat(opt[i], " (reversed)"); strcat(opt[i], " (reversed)");
} }
else { else
opt[i][0] = 0; opt[i][0] = 0;
} }
}
uifc.helpbuf = "`Sort Order`\n\n" uifc.helpbuf = "`Sort Order`\n\n"
"Move the highlight bar to the position you would like\n" "Move the highlight bar to the position you would like\n"
"to add a new ordering before and press ~INSERT~. Choose\n" "to add a new ordering before and press ~INSERT~. Choose\n"
...@@ -739,10 +735,9 @@ edit_sorting(struct bbslist **list, int *listcount, int *ocur, int *obar, char * ...@@ -739,10 +735,9 @@ edit_sorting(struct bbslist **list, int *listcount, int *ocur, int *obar, char *
&(sortorder[(ret & MSK_OFF)]) + 1, &(sortorder[(ret & MSK_OFF)]) + 1,
sizeof(sortorder) - sizeof(sortorder[0]) * ((ret & MSK_OFF) + 1)); sizeof(sortorder) - sizeof(sortorder[0]) * ((ret & MSK_OFF) + 1));
} }
else { else
sortorder[ret & MSK_OFF] = 0 - sortorder[ret & MSK_OFF]; sortorder[ret & MSK_OFF] = 0 - sortorder[ret & MSK_OFF];
} }
}
/* Write back to the .ini file */ /* Write back to the .ini file */
write_sortorder(); write_sortorder();
...@@ -812,9 +807,8 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int ...@@ -812,9 +807,8 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int
else else
entry->has_fingerprint = false; entry->has_fingerprint = false;
} }
else { else
entry->has_fingerprint = false; entry->has_fingerprint = false;
}
entry->sftp_public_key = iniGetBool(section, NULL, "SFTPPublicKey", false); entry->sftp_public_key = iniGetBool(section, NULL, "SFTPPublicKey", false);
iniGetSString(section, NULL, "DownloadPath", home, entry->dldir, sizeof(entry->dldir)); iniGetSString(section, NULL, "DownloadPath", home, entry->dldir, sizeof(entry->dldir));
iniGetSString(section, NULL, "UploadPath", home, entry->uldir, sizeof(entry->uldir)); iniGetSString(section, NULL, "UploadPath", home, entry->uldir, sizeof(entry->uldir));
...@@ -952,14 +946,12 @@ printf_trunc(char *dst, size_t dstsz, char *fmt, char *path) ...@@ -952,14 +946,12 @@ printf_trunc(char *dst, size_t dstsz, char *fmt, char *path)
sprintf(dst, fmt, mangled); sprintf(dst, fmt, mangled);
free(mangled); free(mangled);
} }
else { else
sprintf(dst, fmt, "<Long>"); sprintf(dst, fmt, "<Long>");
} }
} else
else {
sprintf(dst, fmt, path); sprintf(dst, fmt, path);
} }
}
void void
configure_log(struct bbslist *item, const char *itemname, str_list_t inifile, int *changed) configure_log(struct bbslist *item, const char *itemname, str_list_t inifile, int *changed)
...@@ -1004,9 +996,8 @@ configure_log(struct bbslist *item, const char *itemname, str_list_t inifile, in ...@@ -1004,9 +996,8 @@ configure_log(struct bbslist *item, const char *itemname, str_list_t inifile, in
iniSetString(&inifile, itemname, "LogFile", item->logfile, &ini_style); iniSetString(&inifile, itemname, "LogFile", item->logfile, &ini_style);
*changed = 1; *changed = 1;
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 1: case 1:
uifc.helpbuf = "`File Transfer Log Level`\n\n" uifc.helpbuf = "`File Transfer Log Level`\n\n"
...@@ -1176,7 +1167,8 @@ build_edit_list(struct bbslist *item, char opt[][69], int *optmap, char **opts, ...@@ -1176,7 +1167,8 @@ build_edit_list(struct bbslist *item, char opt[][69], int *optmap, char **opts,
int i = 0; int i = 0;
char str[64]; char str[64];
bool is_ansi = true; bool is_ansi = true;
bool is_serial = ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL) || (item->conn_type == CONN_TYPE_SERIAL_NORTS)); bool is_serial = ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL)
|| (item->conn_type == CONN_TYPE_SERIAL_NORTS));
if (!isdefault) { if (!isdefault) {
optmap[i] = BBSLIST_FIELD_NAME; optmap[i] = BBSLIST_FIELD_NAME;
...@@ -1299,7 +1291,8 @@ build_edit_help(struct bbslist *item, int isdefault, char *helpbuf, size_t hbsz) ...@@ -1299,7 +1291,8 @@ build_edit_help(struct bbslist *item, int isdefault, char *helpbuf, size_t hbsz)
{ {
size_t hblen = 0; size_t hblen = 0;
bool is_ansi = true; bool is_ansi = true;
bool is_serial = ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL) || (item->conn_type == CONN_TYPE_SERIAL_NORTS)); bool is_serial = ((item->conn_type == CONN_TYPE_MODEM) || (item->conn_type == CONN_TYPE_SERIAL)
|| (item->conn_type == CONN_TYPE_SERIAL_NORTS));
if (get_emulation(item) != CTERM_EMULATION_ANSI_BBS) if (get_emulation(item) != CTERM_EMULATION_ANSI_BBS)
is_ansi = false; is_ansi = false;
...@@ -1308,12 +1301,10 @@ build_edit_help(struct bbslist *item, int isdefault, char *helpbuf, size_t hbsz) ...@@ -1308,12 +1301,10 @@ build_edit_help(struct bbslist *item, int isdefault, char *helpbuf, size_t hbsz)
* Not using strncpy() here because memset()ing the whole thing * Not using strncpy() here because memset()ing the whole thing
* to NUL here is stupid. * to NUL here is stupid.
*/ */
if (isdefault) { if (isdefault)
hblen = strlcpy(helpbuf, "`Edit Default Connection`\n\n", hbsz); hblen = strlcpy(helpbuf, "`Edit Default Connection`\n\n", hbsz);
} else
else {
hblen = strlcpy(helpbuf, "`Edit Directory Entry`\n\n", hbsz); hblen = strlcpy(helpbuf, "`Edit Directory Entry`\n\n", hbsz);
}
hblen += strlcat(helpbuf + hblen, "Select item to edit.\n\n", hbsz - hblen); hblen += strlcat(helpbuf + hblen, "Select item to edit.\n\n", hbsz - hblen);
...@@ -1458,9 +1449,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1458,9 +1449,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
inifile = iniReadFile(listfile); inifile = iniReadFile(listfile);
fclose(listfile); fclose(listfile);
} }
else { else
inifile = strListInit(); inifile = strListInit();
}
if (isdefault) if (isdefault)
itemname = NULL; itemname = NULL;
...@@ -1478,9 +1468,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1478,9 +1468,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
if (i < -1) if (i < -1)
continue; continue;
// Remember, i gets converted to (unsigned) size_t in comparison // Remember, i gets converted to (unsigned) size_t in comparison
if (i > 0 && i >= (sizeof(optmap) / sizeof(optmap[0]))) { if (i > 0 && i >= (sizeof(optmap) / sizeof(optmap[0])))
continue; continue;
}
if (i >= 0) { if (i >= 0) {
if (optmap[i] == BBSLIST_FIELD_NONE) if (optmap[i] == BBSLIST_FIELD_NONE)
continue; continue;
...@@ -1883,9 +1872,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1883,9 +1872,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
iniSetInteger(&inifile, itemname, "ANSIMusic", item->music, &ini_style); iniSetInteger(&inifile, itemname, "ANSIMusic", item->music, &ini_style);
changed = 1; changed = 1;
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case BBSLIST_FIELD_ADDRESS_FAMILY: case BBSLIST_FIELD_ADDRESS_FAMILY:
uifc.helpbuf = address_family_help; uifc.helpbuf = address_family_help;
...@@ -1901,9 +1889,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef ...@@ -1901,9 +1889,8 @@ edit_list(struct bbslist **list, struct bbslist *item, char *listpath, int isdef
&ini_style); &ini_style);
changed = 1; changed = 1;
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case BBSLIST_FIELD_FONT: case BBSLIST_FIELD_FONT:
uifc.helpbuf = "`Font`\n\n" uifc.helpbuf = "`Font`\n\n"
...@@ -1977,9 +1964,8 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry) ...@@ -1977,9 +1964,8 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry)
inifile = iniReadFile(listfile); inifile = iniReadFile(listfile);
fclose(listfile); fclose(listfile);
} }
else { else
inifile = strListInit(); inifile = strListInit();
}
/* /*
* Redundant: * Redundant:
...@@ -2019,9 +2005,8 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry) ...@@ -2019,9 +2005,8 @@ add_bbs(char *listpath, struct bbslist *bbs, bool new_entry)
if (bbs->has_fingerprint) { if (bbs->has_fingerprint) {
char fp[41]; char fp[41];
fp[0] = 0; fp[0] = 0;
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++)
sprintf(&fp[i * 2], "%02x", bbs->ssh_fingerprint[i]); sprintf(&fp[i * 2], "%02x", bbs->ssh_fingerprint[i]);
}
fp[sizeof(fp) -1] = 0; fp[sizeof(fp) -1] = 0;
iniSetString(&inifile, bbs->name, "SSHFingerprint", fp, &ini_style); iniSetString(&inifile, bbs->name, "SSHFingerprint", fp, &ini_style);
} }
...@@ -2171,9 +2156,8 @@ change_settings(int connected) ...@@ -2171,9 +2156,8 @@ change_settings(int connected)
inicontents = iniReadFile(inifile); inicontents = iniReadFile(inifile);
fclose(inifile); fclose(inifile);
} }
else { else
inicontents = strListInit(); inicontents = strListInit();
}
for (i = 0; i < 13; i++) for (i = 0; i < 13; i++)
opt[i] = opts[i]; opt[i] = opts[i];
...@@ -2375,9 +2359,8 @@ change_settings(int connected) ...@@ -2375,9 +2359,8 @@ change_settings(int connected)
} }
} }
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 5: case 5:
uifc.helpbuf = "`Modem/Comm Device`\n\n" uifc.helpbuf = "`Modem/Comm Device`\n\n"
...@@ -2393,9 +2376,8 @@ change_settings(int connected) ...@@ -2393,9 +2376,8 @@ change_settings(int connected)
settings.mdm.device_name, settings.mdm.device_name,
&ini_style); &ini_style);
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 6: case 6:
uifc.helpbuf = "`Modem/Comm Rate`\n\n" uifc.helpbuf = "`Modem/Comm Rate`\n\n"
...@@ -2413,9 +2395,8 @@ change_settings(int connected) ...@@ -2413,9 +2395,8 @@ change_settings(int connected)
settings.mdm.com_rate, settings.mdm.com_rate,
&ini_style); &ini_style);
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 7: case 7:
...@@ -2446,9 +2427,8 @@ change_settings(int connected) ...@@ -2446,9 +2427,8 @@ change_settings(int connected)
settings.mdm.init_string, settings.mdm.init_string,
&ini_style); &ini_style);
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 8: case 8:
uifc.helpbuf = "`Modem Dial String`\n\n" uifc.helpbuf = "`Modem Dial String`\n\n"
...@@ -2462,9 +2442,8 @@ change_settings(int connected) ...@@ -2462,9 +2442,8 @@ change_settings(int connected)
settings.mdm.dial_string, settings.mdm.dial_string,
&ini_style); &ini_style);
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 9: case 9:
uifc.helpbuf = "`List Path`\n\n" uifc.helpbuf = "`List Path`\n\n"
...@@ -2479,9 +2458,8 @@ change_settings(int connected) ...@@ -2479,9 +2458,8 @@ change_settings(int connected)
if (list_override == NULL) if (list_override == NULL)
SAFECOPY(settings.list_path, settings.stored_list_path); SAFECOPY(settings.list_path, settings.stored_list_path);
} }
else { else
check_exit(false); check_exit(false);
}
break; break;
case 10: case 10:
uifc.helpbuf = "`TERM For Shell`\n\n" uifc.helpbuf = "`TERM For Shell`\n\n"
...@@ -2783,9 +2761,8 @@ edit_comment(struct bbslist *list, char *listpath) ...@@ -2783,9 +2761,8 @@ edit_comment(struct bbslist *list, char *listpath)
inifile = iniReadFile(listfile); inifile = iniReadFile(listfile);
fclose(listfile); fclose(listfile);
} }
else { else
goto done; goto done;
}
old = strdup(list->comment); old = strdup(list->comment);
if (!old) if (!old)
...@@ -2991,9 +2968,8 @@ show_bbslist(char *current, int connected) ...@@ -2991,9 +2968,8 @@ show_bbslist(char *current, int connected)
if (p != NULL) if (p != NULL)
*p = ')'; *p = ')';
} }
else { else
SAFECOPY(title, syncterm_version); SAFECOPY(title, syncterm_version);
}
settitle(title); settitle(title);
} }
oldopt = opt; oldopt = opt;
...@@ -3285,8 +3261,7 @@ show_bbslist(char *current, int connected) ...@@ -3285,8 +3261,7 @@ show_bbslist(char *current, int connected)
case CONN_TYPE_SERIAL_NORTS: case CONN_TYPE_SERIAL_NORTS:
case CONN_TYPE_SHELL: case CONN_TYPE_SHELL:
break; break;
default: default: {
{
char *p = strrchr(list[listcount - 1]->addr + 1, ':'); char *p = strrchr(list[listcount - 1]->addr + 1, ':');
if (p != NULL && p == strchr(list[listcount - 1]->addr, ':')) { if (p != NULL && p == strchr(list[listcount - 1]->addr, ':')) {
char *tp; char *tp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment