-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.k
More file actions
36 lines (30 loc) · 684 Bytes
/
errors.k
File metadata and controls
36 lines (30 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "main.h"
/**
* error_2_syntax - Creates an error message for syntax errors.
* @args: An array of arguments passed to the command.
*
* Return: The error string.
*/
char *error_2_syntax(char **args)
{
char *error, *hist_str;
int len;
hist_str = _itoa(hist);
if (!hist_str)
return (NULL);
len = _strlen(name) + _strlen(hist_str) + _strlen(args[0]) + 33;
error = malloc(sizeof(char) * (len + 1));
if (!error)
{
free(hist_str);
return (NULL);
}
_strcpy(error, name);
_strcat(error, ": ");
_strcat(error, hist_str);
_strcat(error, ": Syntax error: \"");
_strcat(error, args[0]);
_strcat(error, "\" unexpected\n");
free(hist_str);
return (error);
}