git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/strncat.c

      1 #include <string.h>
      2 
      3 /*
      4  * Concatenate s2 on the end of s1. s1 must be large enough.
      5  * At most n characters are moved.
      6  * Return s1.
      7  */
      8 
      9 char *strncat(char *s1, const char *s2, int n) {
     10     char *os1 = s1;
     11     while (*s1++) ;
     12     --s1;
     13     while (*s1++ = *s2++) {
     14         if (n == 0) {
     15             *--s1 = '\0';
     16             break;
     17         }
     18         n--;
     19     }
     20     return os1;
     21 }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.