drivers/accessibility/speakup/i18n.c
Source file repositories/reference/linux-study-clean/drivers/accessibility/speakup/i18n.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accessibility/speakup/i18n.c- Extension
.c- Size
- 19342 bytes
- Lines
- 631
- Domain
- Driver Families
- Bucket
- drivers/accessibility
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/ctype.hlinux/module.hlinux/string.hspeakup.hspk_priv.h
Detected Declarations
function compare_specifiersfunction fmt_validatefunction spk_msg_setfunction spk_reset_msg_groupfunction spk_initialize_msgsfunction spk_free_user_msgs
Annotated Snippet
if (next_percent) {
/* skip over doubled percent signs */
while (next_percent[0] == '%' &&
next_percent[1] == '%')
next_percent += 2;
if (*next_percent == '%')
found = 1;
else if (*next_percent == '\0')
next_percent = NULL;
}
}
return next_percent;
}
/* Skip over 0 or more flags. */
static char *skip_flags(char *input)
{
while ((*input != '\0') && strchr(" 0+-#", *input))
input++;
return input;
}
/* Skip over width.precision, if it exists. */
static char *skip_width(char *input)
{
while (isdigit(*input))
input++;
if (*input == '.') {
input++;
while (isdigit(*input))
input++;
}
return input;
}
/*
* Skip past the end of the conversion part.
* Note that this code only accepts a handful of conversion specifiers:
* c d s x and ld. Not accidental; these are exactly the ones used in
* the default group of formatted messages.
*/
static char *skip_conversion(char *input)
{
if ((input[0] == 'l') && (input[1] == 'd'))
input += 2;
else if ((*input != '\0') && strchr("cdsx", *input))
input++;
return input;
}
/*
* Function: find_specifier_end
* Return a pointer to the end of the format specifier.
*/
static char *find_specifier_end(char *input)
{
input++; /* Advance over %. */
input = skip_flags(input);
input = skip_width(input);
input = skip_conversion(input);
return input;
}
/*
* Function: compare_specifiers
* Compare the format specifiers pointed to by *input1 and *input2.
* Return true if they are the same, false otherwise.
* Advance *input1 and *input2 so that they point to the character following
* the end of the specifier.
*/
static bool compare_specifiers(char **input1, char **input2)
{
bool same = false;
char *end1 = find_specifier_end(*input1);
char *end2 = find_specifier_end(*input2);
size_t length1 = end1 - *input1;
size_t length2 = end2 - *input2;
if ((length1 == length2) && !memcmp(*input1, *input2, length1))
same = true;
*input1 = end1;
*input2 = end2;
return same;
}
/*
* Function: fmt_validate
* Check that two format strings contain the same number of format specifiers,
Annotation
- Immediate include surface: `linux/slab.h`, `linux/ctype.h`, `linux/module.h`, `linux/string.h`, `speakup.h`, `spk_priv.h`.
- Detected declarations: `function compare_specifiers`, `function fmt_validate`, `function spk_msg_set`, `function spk_reset_msg_group`, `function spk_initialize_msgs`, `function spk_free_user_msgs`.
- Atlas domain: Driver Families / drivers/accessibility.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.