Skip to content

Minor changes... #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Fragaria.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
GCC_ENABLE_OBJC_GC = unsupported;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
Expand Down Expand Up @@ -896,6 +897,10 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"NS_BLOCK_ASSERTIONS=1",
"NDEBUG=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
Expand Down
40 changes: 38 additions & 2 deletions Fragaria_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@
// Prefix header for all source files of the 'Fragaria' target in the 'Fragaria' project
//

#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#if defined(__STDC__)
# define C89
# if defined(__STDC_VERSION__)
# define C90
# if (__STDC_VERSION__ >= 199409L)
# define C94
# endif
# if (__STDC_VERSION__ >= 199901L)
# define C99
# endif
# endif
#endif

// Note: Currently in Apple ObjC++, C99 and __cplusplus would both be defined at this point.

#ifdef __OBJC__ /* Xcode 4.5: "Jump to definition" may take multiple attempts for macros. */
# import <Cocoa/Cocoa.h>
# ifdef __cplusplus
# define OBJCPP
# import <climits>
# import <cfloat>
# import <cstdarg>
# import <cstddef>
# import <cstdint>
# import <cstdlib>
# import <ciso646> /* <-- C++98 should already define these keywords */
# elif defined(C99)
# import <limits.h>
# import <float.h>
# import <stdarg.h>
# import <stddef.h>
# import <stdint.h>
# import <stdlib.h>
# import <iso646.h>
# else
# warning Either C99 or __cplusplus should be defined.
# endif
#endif

11 changes: 7 additions & 4 deletions ICUMatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ -(NSString *)group {

-(NSString *)groupAtIndex:(unsigned)groupIndex {
size_t groupSize = InitialGroupSize;
NSAssert(groupSize < INT32_MAX, @"size_t cast later to int32_t");
URegularExpression *re = [[self pattern] re];

while(YES) {
UErrorCode status = 0;
UChar *dest = (UChar *)NSZoneCalloc([self zone], groupSize, sizeof(UChar));
int32_t buffSize = uregex_group(re, groupIndex, dest, groupSize, &status);
int32_t buffSize = uregex_group(re, groupIndex, dest, (int32_t)groupSize, &status);

if(U_BUFFER_OVERFLOW_ERROR == status) {
groupSize *= 2;
Expand Down Expand Up @@ -155,6 +156,7 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace
BOOL replacementCompleted = NO;
int resultLength = 0;
size_t destStringBufferSize = searchTextLength * 2;
NSAssert(destStringBufferSize < INT32_MAX, @"size_t cast later to int32_t");
UChar *destString = NULL;
while(!replacementCompleted) {

Expand All @@ -167,15 +169,16 @@ -(NSString *)performReplacementWithString:(NSString *)aReplacementString replace

status = 0;
if(replacingAll)
resultLength = uregex_replaceAll(re, replacementText, -1, destString, destStringBufferSize, &status);
resultLength = uregex_replaceAll(re, replacementText, -1, destString, (int32_t)destStringBufferSize, &status);
else
resultLength = uregex_replaceFirst(re, replacementText, -1, destString, destStringBufferSize, &status);
resultLength = uregex_replaceFirst(re, replacementText, -1, destString, (int32_t)destStringBufferSize, &status);

// realloc some more space if possible
if(status == U_BUFFER_OVERFLOW_ERROR) {

destStringBufferSize = resultLength + 1;

NSAssert(destStringBufferSize < INT32_MAX, @"size_t cast later to int32_t");

UChar *prevString = destString;
destString = NSZoneRealloc([self zone], destString, destStringBufferSize*sizeof(UChar));

Expand Down
8 changes: 4 additions & 4 deletions ICUPattern.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ -(NSArray *)componentsSplitFromString:(NSString *)stringToSplit
UChar *destFields[destFieldsCapacity];
int numberOfComponents = uregex_split([self re],
destBuf,
destCapacity,
(int32_t)destCapacity,
&requiredCapacity,
destFields,
destFieldsCapacity,
&status);

if(status == U_BUFFER_OVERFLOW_ERROR) { // buffer was too small, grow it
NSZoneFree([self zone], destBuf);
NSAssert(destCapacity * 2 < INT_MAX, @"Overflow occurred splitting string.");
NSAssert(destCapacity * 2 < INT32_MAX, @"Overflow occurred splitting string.");
destCapacity = (destCapacity < (unsigned)requiredCapacity) ? (unsigned)requiredCapacity : destCapacity * 2;
status = 0;
} else if(destFieldsCapacity == numberOfComponents) {
destFieldsCapacity *= 2;
NSAssert(destFieldsCapacity *2 < INT_MAX, @"Overflow occurred splitting string.");
NSAssert(destFieldsCapacity *2 < INT32_MAX, @"Overflow occurred splitting string.");
NSZoneFree([self zone], destBuf);
status = 0;
} else if(U_FAILURE(status)) {
Expand All @@ -231,7 +231,7 @@ -(NSArray *)componentsSplitFromString:(NSString *)stringToSplit

if(U_FAILURE(status))
[NSException raise:@"Split Exception"
format:@"Unable to split string: %@", u_errorName(status)];
format:@"Unable to split string: %s", u_errorName(status)];

return [NSArray arrayWithArray:results];
}
Expand Down
2 changes: 1 addition & 1 deletion MGSSyntaxController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
- (NSDictionary *)syntaxDefinitionWithExtension:(NSString *)extension;
- (NSString *)syntaxDefinitionNameWithExtension:(NSString *)extension;

@property (nonatomic,readonly) NSArray *syntaxDefinitionNames;
@property (retain) NSArray *syntaxDefinitionNames;

@end
1 change: 0 additions & 1 deletion MGSSyntaxController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ - (NSDictionary *)standardSyntaxDefinition;
- (NSDictionary *)syntaxDefinitionWithName:(NSString *)name;
- (NSBundle *)bundle;

@property (retain) NSArray *syntaxDefinitionNames;
@property (retain) NSMutableDictionary *syntaxDefinitions;

@end
Expand Down
2 changes: 1 addition & 1 deletion NSScanner+Fragaria.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ - (void)mgs_setScanLocation:(NSUInteger)idx
*/
NSUInteger maxIndex = [[self string] length];
if (idx > maxIndex) {
NSLog(@"Invalid scan location %u > max of %u", idx, maxIndex);
NSLog(@"Invalid scan location %lu > max of %lu", idx, maxIndex);
idx = maxIndex;
}

Expand Down
4 changes: 2 additions & 2 deletions SMLLineNumbers.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ - (void)updateLineNumbersForClipView:(NSClipView *)clipView checkWidth:(BOOL)che
while (indexNonWrap <= maxRangeVisibleRange) {
if (idx == indexNonWrap) {
lineNumber++;
[lineNumbersString appendFormat:@"%i\n", lineNumber];
[lineNumbersString appendFormat:@"%li\n", lineNumber];
} else {
[lineNumbersString appendFormat:@"%C\n", 0x00B7];
[lineNumbersString appendFormat:@"%C\n", (uint16_t)0xB7];
indexNonWrap = idx;
}

Expand Down
8 changes: 4 additions & 4 deletions SMLTextPerformer.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ - (id)init
self = [super init];
sharedInstance = self;

darkSideLineEnding = [[NSString alloc] initWithFormat:@"%C%C", 0x000D, 0x000A];
macLineEnding = [[NSString alloc] initWithFormat:@"%C", 0x000D];
unixLineEnding = [[NSString alloc] initWithFormat:@"%C", 0x000A];
darkSideLineEnding = [[NSString alloc] initWithFormat:@"%C%C", (uint16_t)0x0D, (uint16_t)0x0A];
macLineEnding = [[NSString alloc] initWithFormat:@"%C", (uint16_t)0x0D];
unixLineEnding = [[NSString alloc] initWithFormat:@"%C", (uint16_t)0x0A];

newLineSymbolString = [[NSString alloc] initWithFormat:@"%C", 0x23CE];
newLineSymbolString = [[NSString alloc] initWithFormat:@"%u", (uint32_t)0x23CE];
}
return sharedInstance;
}
Expand Down
2 changes: 1 addition & 1 deletion SMLTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ - (void)setTabWidth
- (void)setPageGuideValues
{
NSDictionary *sizeAttribute = [[[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[SMLDefaults valueForKey:@"TextFont"]], NSFontAttributeName, nil] autorelease];
NSString *sizeString = [NSString stringWithString:@" "];
NSString *sizeString = @" ";
CGFloat sizeOfCharacter = [sizeString sizeWithAttributes:sizeAttribute].width;
pageGuideX = (sizeOfCharacter * ([[SMLDefaults valueForKey:@"ShowPageGuideAtColumn"] integerValue] + 1)) - 1.5f; // -1.5 to put it between the two characters and draw only on one pixel and not two (as the system draws it in a special way), and that's also why the width above is set to zero

Expand Down