Revision: 27775
http://sourceforge.net/p/bibdesk/svn/27775
Author: hofman
Date: 2022-07-28 14:30:41 +0000 (Thu, 28 Jul 2022)
Log Message:
-----------
capture c-string and count of unique characters in block rather than as
arguments
Modified Paths:
--------------
trunk/bibdesk/BDSKFormatParser.m
Modified: trunk/bibdesk/BDSKFormatParser.m
===================================================================
--- trunk/bibdesk/BDSKFormatParser.m 2022-07-28 09:44:23 UTC (rev 27774)
+++ trunk/bibdesk/BDSKFormatParser.m 2022-07-28 14:30:41 UTC (rev 27775)
@@ -871,28 +871,30 @@
memset(fallback, NSMaxRange(charRange) - 1, number);
}
- __block NSString *(^uniqueString)(char *, NSUInteger, NSUInteger) =
^NSString *(char *chars, NSUInteger count, NSUInteger i) {
- if (i < count) {
- char c;
- for (c = charRange.location; c < (char)NSMaxRange(charRange); c++)
{
- if (number == 0 && i == 0 && c == '0') continue;
- chars[i] = c;
- NSString *str = uniqueString(chars, count, i + 1);
- if (str) return str;
- }
- return nil;
- } else {
- return validator([NSString stringWithFormat:@"%@%s%@", baseStr,
chars, endStr]);
- }
- };
-
// run along characters to find one that is unique
n = MAX(number, 1);
do {
- char chars[n + 1];
- memset(chars, '\0', n + 1);
- if ((uniqueStr = uniqueString(chars, n++, 0)))
+ char chs[n + 1], *chars = chs;
+ memset(chs, '\0', n + 1);
+
+ __block NSString *(^uniqueString)(NSUInteger) = ^NSString *(NSUInteger
i) {
+ if (i < n) {
+ char c;
+ for (c = charRange.location; c < (char)NSMaxRange(charRange);
c++) {
+ if (number == 0 && i == 0 && c == '0') continue;
+ chars[i] = c;
+ NSString *str = uniqueString(i + 1);
+ if (str) return str;
+ }
+ return nil;
+ } else {
+ return validator([NSString stringWithFormat:@"%@%s%@",
baseStr, chars, endStr]);
+ }
+ };
+
+ if ((uniqueStr = uniqueString(0)))
return uniqueStr;
+ n++;
} while (number == 0);
// we did not find a unique one, so just use the hash value or the final
try
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit