@@ -147,7 +147,10 @@ defmodule IO do
147
147
end
148
148
149
149
@ doc """
150
- Gets `count` bytes from the IO device. It returns:
150
+ Gets a number of bytes from the io device. If the
151
+ io device is an unicode device, count implies
152
+ the number of unicode codepoints to be retrieved.
153
+ Otherwise, the number of raw bytes. It returns:
151
154
152
155
* `data` - The input characters.
153
156
@@ -157,21 +160,43 @@ defmodule IO do
157
160
for instance {:error, :estale} if reading from an
158
161
NFS file system.
159
162
"""
163
+ def getn ( prompt , count // 1 )
164
+
165
+ def getn ( prompt , count ) when is_integer ( count ) do
166
+ getn ( group_leader , prompt , count )
167
+ end
168
+
169
+ def getn ( device , prompt ) do
170
+ getn ( device , prompt , 1 )
171
+ end
172
+
173
+ @ doc """
174
+ Gets a number of bytes from the io device. If the
175
+ io device is an unicode device, count implies
176
+ the number of unicode codepoints to be retrieved.
177
+ Otherwise, the number of raw bytes.
178
+ """
179
+ def getn ( device , prompt , count ) do
180
+ :io . get_chars ( map_dev ( device ) , to_iodata ( prompt ) , count )
181
+ end
182
+
183
+ @ doc false
160
184
def getb ( prompt , count // 1 )
161
185
162
186
def getb ( prompt , count ) when is_integer ( count ) do
163
- getb ( group_leader , prompt , count )
187
+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
188
+ getn ( prompt , count )
164
189
end
165
190
166
191
def getb ( device , prompt ) do
167
- getb ( device , prompt , 1 )
192
+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
193
+ getn ( device , prompt )
168
194
end
169
195
170
- @ doc """
171
- Gets `count` bytes from the chosen IO device.
172
- """
196
+ @ doc false
173
197
def getb ( device , prompt , count ) do
174
- :io . get_chars ( map_dev ( device ) , to_iodata ( prompt ) , count )
198
+ IO . write "[WARNING] IO.getb is deprecated, please use IO.getn instead\n #{ Exception . format_stacktrace } "
199
+ getn ( device , prompt , count )
175
200
end
176
201
177
202
@ doc """
0 commit comments