Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

util: suppress some uninitialized variable warnings#6659

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethomson merged 5 commits intolibgit2:mainfromboretrk:fixwarn
Dec 14, 2023

Conversation

boretrk
Copy link
Contributor

A couple of warnings were uncovered in#6655
This should take care of the easy ones.

The larger problem is the ctype warnings where we have a bit of a mix between using the properisalnum() and rolling our own withgit__isalnum()
The posix versions take an integer in to be able to handle EOF fromfgetc() so when a char is passed it has to be casted to unsigned so that 128-255 isn't extended to negative integers.
Thegit__isalnum() function takes care of it by simply not handling characters outside of the ascii set and will behave incorrectly on systems using ISO-8859-1 or other charsets using more than 7 bits.

I'm not entirely sure why we have thegit__isalnum() functions. I assume it is to support systems wherectype.h isn't available?
In that case I think the current implementation should be used only when ctype doesn't exists.
There is also the thing where casting characters to unsigned everywhere is a bit tedious, so maybe we should change the functions to take an unsigned char in?

@boretrk
Copy link
ContributorAuthor

Also replaced index() with strchr(). index() isn't POSIX and won't compile on some systems.
I also got some compiler warnings in errors.c because the deprecated stuff weren't pre-declared.

ethomson reacted with thumbs up emoji

In C99 functions need to be declared before they are defined.We could just add the declarations before them, but including theheader allows the compiler to warn if they differ.
@boretrk
Copy link
ContributorAuthor

OK, I think this one is good to go now.
The character classification stuff will probably have to be its own thing.

Thegit__isalpha() stuff seems to have been added in0f49200 to solve issues with the config parsing so it should probably be left alone?
Over all it seems like we need a set of character type functions that behaves as if locale is set to"C" but is this really always the case?
So when is it correct to use locale sensitive character type classification and when shall we use the git__xxxx() versions?

For reference: When locale is set to "C" we get ISO/IEC 9899:1999 5.2.1 Character sets:

  1. Both the basic source and basic execution character sets shall have the following members: the 26 uppercase letters of the Latin alphabet
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    the 26 lowercase letters of the Latin alphabet
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    the 10 decimal digits
    0 1 2 3 4 5 6 7 8 9
    the following 29 graphic characters
    ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~
    the space character, and control characters representing horizontal tab, vertical tab, and form feed.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ethomsonethomsonethomson approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@boretrk@ethomson

[8]ページ先頭

©2009-2025 Movatter.jp