Git Product home page Git Product logo

xlymian / git Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 13.0 13.01 MB

GitHub mirror of the publicly available git repo, updated hourly. It's here so we can use the collaboration tools of GitHub. Updates ONLY from git public repo. If you want changes pulled, contact the git team, not me.

License: Other

Shell 23.38% Makefile 1.11% C 46.81% Assembly 0.22% Perl 13.49% Emacs Lisp 1.75% Python 2.43% Vim Script 0.02% Tcl 10.64% JavaScript 0.02% CSS 0.14% Objective-C 0.01%

git's People

Contributors

andyparkins avatar chriscool avatar drafnel avatar dscho avatar flichtenheld avatar gitster avatar glandium avatar hanwen avatar hjemli avatar iabervon avatar jnareb avatar jonas avatar julliard avatar kvaneesh avatar loops avatar ltuikov avatar madcoder avatar matled avatar meyering avatar pasky avatar paulusmack avatar peff avatar pugmajere avatar raalkml avatar sigprof avatar smurfix avatar spearce avatar sprohaska avatar torvalds avatar tronical avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git's Issues

Is this a bug?

Use gcc to compile the following code and run it with command ./a.out -t, decode_85() goes to:
say1("invalid base85 alphabet (%c)\n",ch); return -1;

#include <string.h>
#include <stdio.h>
//#undef DEBUG_85
#define DEBUG_85

#ifdef DEBUG_85
#define say(a) fprintf(stderr, a)
#define say1(a,b) fprintf(stderr, a, b)
#define say2(a,b,c) fprintf(stderr, a, b, c)
#else
#define say(a) do { /* nothing */ } while (0)
#define say1(a,b) do { /* nothing */ } while (0)
#define say2(a,b,c) do { /* nothing */ } while (0)
#endif


static const char en85[] = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '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',
    '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',
    '!', '#', '$', '%', '&', '(', ')', '*', '+', '-',
    ';', '<', '=', '>', '?', '@', '^', '_', '`', '{',
    '|', '}', '~'
};

static char de85[256];
static void prep_base85(void)
{
    if (de85['Z'])
        return;
    int i;
    for (i = 0; i < sizeof(en85); i++) {
        int ch = en85[i];
        de85[ch] = i + 1;
    }
}


int decode_85(char *dst, const char *buffer, int len)
{
const char *start=buffer;
    prep_base85();
    say2("decoding=>(given len=%d,converted len=%d)",len,len/4*5);
    say2(" decoding str:(%.*s)", len/4*5, buffer);
    while (len) {
say1("\n(loop len=%d) ",len);
        unsigned acc = 0;
        int de, cnt = 4;
        unsigned char ch;
        do {
            ch = *buffer++;
say1("%c",ch);
            de = de85[ch];
            if (--de < 0){
                //return error("invalid base85 alphabet %c", ch);
                say1("invalid base85 alphabet (%c)\n",ch); return -1;
            }
            acc = acc * 85 + de;
        } while (--cnt);
        ch = *buffer++;
say1("%c",ch);
        de = de85[ch];
        if (--de < 0){
            //return error("invalid base85 alphabet %c", ch);
            say("error -2\n"); return -2;
        }
        /* Detect overflow. */
        if (0xffffffff / 85 < acc || 0xffffffff - de < (acc *= 85)){
            //return error("invalid base85 sequence %.5s", buffer-5);
            say("error -3\n"); return -3;
        }
        acc += de;
        say1(" %08X", acc);
        cnt = (len < 4) ? len : 4;
        len -= cnt;
        do {
            acc = (acc << 8) | (acc >> 24);
            *dst++ = acc;
        } while (--cnt);
    }
    say1("\n",len);
    //return 0;
return buffer-start;
}

//#ifdef DEBUG_85
int main(int ac, char **av)
{
    char buf[1024];

    if (!strcmp(av[1], "-e")) {
        int len = strlen(av[2]);
        encode_85(buf, av[2], len);
        if (len <= 26) len = len + 'A' - 1;
        else len = len + 'a' - 26 - 1;
        printf("encoded:%c%s\n", len, buf);
        return 0;
    }
    if (!strcmp(av[1], "-d")) {
        int len = *av[2];
        if ('A' <= len && len <= 'Z') len = len - 'A' + 1;
        else len = len - 'a' + 26 + 1;
        decode_85(buf, av[2]+1, len);
        printf("decoded:%.*s\n", len, buf);
        return 0;
    }
    if (!strcmp(av[1], "-t")) {
        /*
        char t[4] = { -1,-1,-1,-1 };
        encode_85(buf, t, 4);
        printf("encoded: D%s\n", buf);
        return 0;
        */
        char encoded[1024];
        char decoded[1024];
        const char instring[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZa";
        int encoded_len=encode_85(encoded,instring,strlen(instring));
        decode_85(decoded,encoded,encoded_len);
say2("inlen=%d,outlen=%d",strlen(instring),encoded_len);
say1("\n%s\n",decoded);
        return 0;
    }
}
//#endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.