
1. --except-files 등록하기 A. rm.c 파일에 Long type 옵션 등록 Short type option인 -b가 ‘invalid option’으로 인식되는 문제를 해결하지 못하였지만, 일단 Long type option인 --except-files를 등록하였다. struct option { const char *name; /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /coreutils/lib/getopt-ext.h 파일에는 option 구조..

1. --help로 -b와 --except-files 출력 A. --help 출력 함수에 옵션 설명 추가 void usage (int status) { if (status != EXIT_SUCCESS) emit_try_help (); else { printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name); fputs (_("\ Remove (unlink) the FILE(s).\n\ \n\ -f, --force ignore nonexistent files and arguments, never prompt\n\ -i prompt before every removal\n\ "), stdout); ... fputs (_("\ -r, -R, --recursiv..

1. rm.c가 include한 헤더 파일 위치 파악 저번 주에 coreutils를 실행하기 위한 작업을 진행하였다. 그 결과 git clone한 coreutils 디렉터리에 실행에 필요한 여러 파일이 추가되어 디렉터리 내용이 많이 바뀌었다. 그중 rm.c 파일과 이와 연관된 파일만 분석하였다. 위 사진은 rm.c 파일의 include 부분을 캡처한 것이다. C언어 표준 라이브러리 stdio.h, assert.h, sys/types.h /coreutils/lib config.h, argmatch.h, error.h, root-dev-ino.h, yesno.h, priv-set.h /coreutils/src system.h, die.h, remove.h /gcc/include (별도 파일) getopt.h..

https://www.acmicpc.net/problem/1920 1920번: 수 찾기 첫째 줄에 자연수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 N개의 정수 A[1], A[2], …, A[N]이 주어진다. 다음 줄에는 M(1 ≤ M ≤ 100,000)이 주어진다. 다음 줄에는 M개의 수들이 주어지는데, 이 수들 www.acmicpc.net 1. 문제 2. 정답 코드 import sys input = sys.stdin.readline # input()보다 빠른 sys.stdin.readline() 사용 # n n = int(input()) ns = list(map(int, input().split())) ns.sort() # 이진 탐색을 위한 오름차순 정렬 # m m = int(inpu..

https://www.acmicpc.net/problem/1924 1924번: 2007년 첫째 줄에 빈 칸을 사이에 두고 x(1 ≤ x ≤ 12)와 y(1 ≤ y ≤ 31)이 주어진다. 참고로 2007년에는 1, 3, 5, 7, 8, 10, 12월은 31일까지, 4, 6, 9, 11월은 30일까지, 2월은 28일까지 있다. www.acmicpc.net 1. 문제 2. 정답 코드 m, d = map(int, input().split()) MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] DAYS = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'] # 1월 1일 월요일 total_days = d # 입력 월의 day..