Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
20 changes: 10 additions & 10 deletions lib/libft/ft_memmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/28 13:44:03 by ttsubo #+# #+# */
/* Updated: 2024/12/23 19:56:10 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:10:56 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

/**
* @brief src領域をdst領域にオーバーラップを考慮したコピーを行います。
* @brief Copy the src area to the dst area considering overlap.
*
* @param [out] dst : コピー先のメモリ領域
* @param [in] src : コピー元のメモリ領域
* @param [in] len : コピーする領域の長さ
* @return void* : dstを返します
* @param [out] dst :
* @param [in] src :
* @param [in] len :
* @return void* : return dst
* @note :
* dstとsrcのメモリアドレス番地の位置で挙動が変わります。
* dst < src なら前方からコピー
* dst == src ならdをそのまま返す(内容が同じのため)
* それ以外は後方コピーを行います
* The behavior of this function changes with the position of dst and src.
* If dst < src, copy from the front.
* If dst == src, returns dst as is.
* Otherwise, copy from behind.
*/
void *ft_memmove(void *dst, const void *src, size_t len)
{
Expand Down
18 changes: 9 additions & 9 deletions lib/libft/ft_memset.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/28 11:54:35 by ttsubo #+# #+# */
/* Updated: 2024/12/23 19:38:03 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:14:49 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

/**
* @brief メモリ領域bを文字cで穴埋めします
* @brief Fill memory area b with letter c.
*
* @param [out] b : メモリ領域
* @param [in] c : 穴埋めする文字
* @param [in] len : 穴埋めする長さ
* @retval void* : 穴埋めしたメモリ領域
* @retval NULL : bがNULLの場合
* @param [out] b : memory area
* @param [in] c : fill letter
* @param [in] len : length
* @retval void* : return b;
* @retval NULL : If b is NULL.
* @note :
* 内部でuchar型にキャストするので、
* 0-255の範囲外の数字は上位ビットが無視された値で使われます。
* This function internally casts int c to uchar.
* Therefore, upper bits outside the range 0-255 are ignored in its operation.
*/
void *ft_memset(void *b, int c, size_t len)
{
Expand Down
24 changes: 12 additions & 12 deletions lib/libft/ft_printf/srcs/ft_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/11 14:24:10 by ttsubo #+# #+# */
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:35:04 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_printf.h"

/**
* @brief strが%の場合それに応じたフォーマットを出力します
*
* @param str : %[csdiu%]
* @param args : formatに関する引数
* @return int : 出力した文字列の長さ
* @note pre: %からはじまること
* @brief If str is %, output format accordingly
*
* @param str
* @param args
* @return int
*/
static int _format(const char **str, va_list *args)
{
Expand Down Expand Up @@ -50,11 +49,12 @@ static int _format(const char **str, va_list *args)
}

/**
* @brief 渡された引数をフォーマットに従って変換し標準出力に出力します
*
* @param [in] str : 出力する文字列(フォーマットを含む場合もある)
* @param [in] ... : フォーマットに与える変数
* @return int : 出力した文字列の長さ
* @brief Outputs str to standard output.
* If arguments are present, they are converted to match the format.
*
* @param str
* @param ...
* @return int
*/
int ft_printf(const char *str, ...)
{
Expand Down
46 changes: 23 additions & 23 deletions lib/libft/ft_printf/srcs/ft_printf_utils1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/05 15:09:58 by ttsubo #+# #+# */
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:28:10 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_printf_utils.h"

/**
* @brief fdに文字cを出力します
* @brief Outputs the letter c to fd.
*
* @param c : 文字
* @param fd : ファイルディスクリプタ
* @return size_t : 文字の長さ(おおよそ1)
* @param c : char
* @param fd : file descriptor
* @return size_t : char length.(approximately 1)
*/
size_t ptf_putchar_fd(char c, int fd)
{
return (write(fd, &c, 1));
}

/**
* @brief 文字列sをfdに出力します
* @brief Outputs the string s to fd.
*
* @param s : 文字列
* @param fd : ファイルディスクリプタ
* @return size_t : 文字列の長さ
* @param s : string
* @param fd : file descriptor
* @return size_t : string length
*/
size_t ptf_putstr_fd(char *s, int fd)
{
Expand All @@ -44,11 +44,11 @@ size_t ptf_putstr_fd(char *s, int fd)
}

/**
* @brief 符号ありの数字numをfdに出力します
* @brief Outputs the signed n num to fd.
*
* @param num : 符号あり整数
* @param fd : ファイルディスクリプタ
* @return size_t : 符号なし数値の長さ
* @param num : int
* @param fd : file descriptor
* @return size_t : n length
*/
size_t ptf_putnum_fd(int n, int fd)
{
Expand All @@ -73,11 +73,11 @@ size_t ptf_putnum_fd(int n, int fd)
}

/**
* @brief 符号なしの数字unumをfdに出力します
* @brief Output unsigned number n to fd.
*
* @param unum : 符号なし数値
* @param fd : ファイルディスクリプタ
* @return size_t : 符号なし数値の長さ
* @param n : ungigned number
* @param fd : file descriptor
* @return size_t : n length
*/
size_t ptf_putunum_fd(unsigned int n, int fd)
{
Expand All @@ -94,13 +94,13 @@ size_t ptf_putunum_fd(unsigned int n, int fd)
}

/**
* @brief 符号なし整数を16進数形式の文字列で出力します
* @brief Output unsigned integer as string in hexadecimal format.
*
* @param num : 変換する符号なし整数
* @param fd : ファイルディスクリプタ
* @param is_upper : 大文字表記にするかのフラグ(1だと有効)
* @return char* : 変換後の文字列の先頭ポインタ
* @note : pre: 負の数は呼び出し元で変換すること
* @param num : Unsigned integer to convert
* @param fd : file descriptor
* @param is_upper : Flag for capitalization (1 means valid)
* @return char* : First pointer of converted string
* @note : pre: Negative numbers must be converted at the caller
*/
size_t ptf_puthex_fd(unsigned int n, int fd, int is_upper)
{
Expand Down
32 changes: 16 additions & 16 deletions lib/libft/ft_printf/srcs/ft_printf_utils2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/05 15:09:58 by ttsubo #+# #+# */
/* Updated: 2025/01/24 10:58:19 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:31:43 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_printf_utils.h"

/**
* @brief ptf_putptr_fdのアドレス出力用の再帰関数
*
* @param hex : 16進数のアドレス
* @param fd : ファイルディスクリプタ
* @return size_t : 出力した文字の長さ
* @brief Recursive function for ptf_putptr_fd address output
*
* @param hex
* @param fd
* @return size_t
*/
static size_t _ptf_putptr_fd_rec(uintptr_t hex, int fd)
{
Expand All @@ -34,11 +34,11 @@ static size_t _ptf_putptr_fd_rec(uintptr_t hex, int fd)
}

/**
* @brief ポインタを16進数形式で出力します
*
* @param ptr : アドレスを出力したいポインタ
* @param fd : ファイルディスクリプタ
* @return size_t : 出力した文字列の長さ
* @brief Output pointer in hexadecimal format
*
* @param ptr
* @param fd
* @return size_t
*/
size_t ptf_putptr_fd(void *ptr, int fd)
{
Expand All @@ -52,12 +52,12 @@ size_t ptf_putptr_fd(void *ptr, int fd)
}

/**
* @brief メモリ領域bをcで長さlenまで埋めます
* @brief Fill memory area b with letter c.
*
* @param b : メモリ領域
* @param c : 埋める形式 (0-255までの数値)
* @param len : 埋める長さ
* @return void* : 適用後のメモリ領域の先頭アドレス
* @param b
* @param c
* @param len
* @return void*
*/
void *ftp_memset(void *b, int c, size_t len)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/libft/ft_strlen_until.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/15 15:38:39 by ttsubo #+# #+# */
/* Updated: 2025/02/15 15:42:27 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:16:08 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

/**
* @brief 文字stopまでの文字列sの長さを返します。
* @brief Returns the length of string s up to character stop.
*
* @param s
* @param stop
* @return size_t
* @note stopが見つからない場合、文字列sの長さが返されます。
* @note If stop not found, return s length.
*/
size_t ft_strlen_until(const char *s, char stop)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/libft/ft_strnlen.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/15 15:30:54 by ttsubo #+# #+# */
/* Updated: 2025/02/15 15:43:15 by ttsubo ### ########.fr */
/* Updated: 2025/04/27 15:18:11 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

/**
* @brief 文字列sを長さnまでのsの文字数を返します。
* @brief Returns the number of characters in string s up to length n.
*
* @param s
* @param n
* @return size_t
* @note ft_memchrで見つからなかった場合、nがそのまま返されます。
* @note If the return value of ft_memchr is NULL, return n.
*/
size_t ft_strnlen(const char *s, size_t n)
{
Expand Down
Loading